# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
988978 | MateiKing80 | Park (BOI16_park) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
struct DSU
{
vector<int> papa;
DSU (int N)
{
papa.resize(N + 1);
for(int i = 1; i <= N; i ++)
papa[i] = -1;
}
int real_papa(int u)
{
if(papa[u] < 0)
return u;
return papa[u] = real_papa(papa[u]);
}
void join(int u, int v)
{
u = real_papa(u);
v = real_papa(v);
if(papa[u] < papa[v])
swap(u, v);
papa[u] += papa[v];
papa[v] = u;
}
bool query(int u, int v)
{
return real_papa(u) == real_papa(v);
}
};
struct debagat
{
int u, v, timp;
};
bool operator < (debagat a, debagat b)
{
return a.timp < b.timp;
}
struct point
{
int x, y, r;
};
int main()
{
int n, m;
cin >> n >> m;
vector<point> p(n + 1);
DSU ds(n + 4);
for(int i = 1; i <= n; i ++)
cin >> p[i].x >> p[i].y >> p[i].r;
for(int i = 1; i <= n; i ++)
}