constructive algorithms geometry math *1300

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;


using namespace __gnu_pbds;

template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define pb push_back
#define ii pair<int, int>
#define int long long
#define fi first
#define se second
#define fou(i, a, b) for (int i = a; i <= b; ++i)
#define fod(i, a, b) for (int i = a; i >= b; --i)
#define all(v) (v).begin(), (v).end()
#define MAX_N 10000000
#define el '\n'

typedef long long ll;
const int mxN = 1e5 + 9;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)4e18 + 7LL;

const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0} ;


struct DSU {
    vector<int> par, rank;
    DSU() {}
    DSU(int n): par(n, -1), rank(n, -1) {}
    int root(int u) {
        return (par[u] < 0 ? u : par[u] = root(par[u]));
    }

    int sameSet(int u, int v) {
        return root(u) == root(v);
    }

    int size(int u) {
        return -par[root(u)];
    }
    int unite(int u, int v) {
        int x = root(u);
        int y = root(v);
        if (x == y) return 0;


        if (par[x] > par[y]) {
            swap(x,y);
        }

    //    par[x] += par[y];
        par[y] = x;

        return 1;
    }
};

template<class T> T Kruskal(int n2, vector<pair<T, pair<int, int>>> edges) {
    sort(all(edges));
    T ans = 0;
    DSU dsu(n2 + 1);
    for (auto &d : edges) {
        int x = d.se.fi;
        int y = d.se.se;
        if (dsu.unite(x, y)) {
            ans = max(ans, d.fi);
        }
    }
    return (dsu.size(1) == n2 ? ans : -1);
}


int TREE[mxN];
void update(int id, int l, int r, int i, int val) {
    if (i > r || i < l) return;
    if (l == r) {
        TREE[id] = val;
        return;
    }
    int m = (l + r) >> 1;
    update(2 * id, l, m, i, val);
    update(2 * id + 1 ,m + 1, r, i, val);
    TREE[id] = max(TREE[2 * id], TREE[2 * id + 1]);
}

int query(int id, int l, int r, int x, int y) {
    if (l > y || r < x ) return -1;
    if (l >= x && r <= y) return TREE[id];
    int m = (l + r) >> 1;
    int res = query(2 * id, l, m, x, y) ;
    int res2 = query(2 * id + 1, m + 1, r, x, y);
    return max(res, res2);
} 


int a[mxN];
int l[mxN], r[mxN];
int pref[mxN], pref2[mxN];
int32_t main() {
    if (fopen("bonus.inp", "r")) {
        freopen("bonus.inp" ,"r", stdin);
        freopen("bonus.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k; cin >> n >> k;
    if (n == 3) {
        cout << "1 2 3";
    } else if (n == 4) {
        if (abs(90 - k) < abs(45 - k)) {
            cout << "1 2 3";
        } else {
            cout << "1 2 4";
        }
    } else {
        int tmp = 2 + (90 + n * k) / 180;
        if (tmp > n) tmp = n;
        if (tmp < 3) tmp = 3;
        cout << "2 1 " << tmp ;
    }
    return 0 ;
}


Comments

Submit
0 Comments
More Questions

Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number
Lexical Sorting Reloaded
1514A - Perfectly Imperfect Array
580A- Kefa and First Steps
1472B- Fair Division
996A - Hit the Lottery
MSNSADM1 Football
MATCHES Playing with Matches
HRDSEQ Hard Sequence
DRCHEF Doctor Chef
559. Maximum Depth of N-ary Tree
821. Shortest Distance to a Character
1441. Build an Array With Stack Operations