Submission #935733

# Submission time Handle Problem Language Result Execution time Memory
935733 2024-02-29T12:51:17 Z Neco_arc Park (BOI16_park) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include <bits/debug.hpp>
#endif // ONLINE_JUDGE

#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define Neco "Park"
#define resp(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define getbit(x,i) ((x >> i)&1)
#define _left id * 2, l, mid
#define _right id * 2 + 1, mid + 1, r
#define cntbit(x) __builtin_popcountll(x)
#define fi(i, a, b) for(int i = a; i <= b; i++)
#define fid(i, a, b) for(int i = a; i >= b; i--)
#define maxn (int) 2e5 + 7
#define int long long

using namespace std;

const ll mod = 1e9 + 7; //972663749
const ll base = 911382323;
const pair<int, int> sth[] = {{1, 2}, {2, 3}, {3, 4}, {1, 4}, {1, 3}, {2, 4}};

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll GetRandom(ll l, ll r)
{
    return uniform_int_distribution<ll> (l, r)(rng);
}

int n, q, W, H;
int ans[5][5];
tuple<int, int, int> circle[maxn];
struct dl {int x, y, w; };
vector<dl> E;

vector<pair<int, int>> Case[6];
void init() {
    Case[0] = {{1, 4}, {1, 3}, {1, 2}};
    Case[1] = {{2, 1}, {2, 4}, {2, 3}};
    Case[2] = {{3, 2}, {3, 1}, {3, 4}};
    Case[3] = {{4, 3}, {4, 2}, {4, 1}};
    Case[4] = {{1, 3}, {2, 4}, {1, 4}, {2, 3}};
    Case[5] = {{1, 3}, {2, 4}, {1, 2}, {3, 4}};
}


struct DSU {
    int lab[maxn];

    void init(int N) {
        fi(i, 1, N) lab[i] = -1;
    }

    int get_rt(int u) { return lab[u] < 0 ? u : lab[u] = get_rt(lab[u]); }

    void uni(int u, int v) {
        int p = get_rt(u), q = get_rt(v); if(p == q) return;
        if(lab[p] > lab[q]) swap(p, q);
        lab[p] += lab[q], lab[q] = p;
    }
} dsu;

ll calc(ll x, ll y) {
    return sqrt(x * x + y * y);
}

void solve()
{

    cin >> n >> q >> W >> H;
    dsu.init(n + 4), init();

    fi(i, 1, n) {
        int x, y, r;
        cin >> x >> y >> r;

        E.push_back({n + 1, i, y - r});
        E.push_back({n + 2, i, W - x - r});
        E.push_back({n + 3, i, H - y - r});
        E.push_back({n + 4, i, x - r});

        circle[i] = {x, y, r};
    }

    fi(i, 1, n - 1) fi(j, i + 1, n)
    {
        int u, v, r1, x, y, r2;
        tie(u, v, r1) = circle[i], tie(x, y, r2) = circle[j];
        E.push_back({i, j, calc(x - u, y - v) - r1 - r2});
    }

    memset(ans, 60, sizeof ans);
    sort(all(E), [](dl x, dl y){
            return x.w < y.w;
         } );

    for(dl p : E)
    {
        dsu.uni(p.x, p.y);
        int u, v;
        fi(i, 0, 5) {
            tie(u, v) = sth[i];
            for(auto [x, y] : Case[i]) {
                if(dsu.get_rt(n + x) == dsu.get_rt(n + y) && ans[u][v] >= 1e9) ans[u][v] = ans[v][u] = p.w;
            }
        }
    }

    fi(_, 1, q) {
        int x, r;
        cin >> r >> x, r *= 2;

        fi(i, 1, 4) if(ans[x][i] >= r) cout << i;
        cout << '\n';
    }


}


main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    if(fopen(Neco".inp", "r")) {
        freopen(Neco".inp", "r", stdin);
        freopen(Neco".out", "w", stdout);
    }


    int nTest = 1;
//    cin >> nTest;


    while(nTest--)
    {
        solve();
    }


    return 0;
}

Compilation message

park.cpp:3:10: fatal error: bits/debug.hpp: No such file or directory
    3 | #include <bits/debug.hpp>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.