# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411466 | mhy908 | Collapse (JOI18_collapse) | 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>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(all(x))
#define press(x) x.erase(unique(all(x)), x.end());
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
const int INF=1e9;
const LL LLINF=1e18;
const int BUC=300;
struct UNION_FIND{
int par[100010], sz[100010], cnt;
vector<int> vc;
void init(int num){for(int i=1; i<=num; i++)par[i]=i, sz[i]=1; cnt=0;}
int findpar(int num){return num==par[num]?num:findpar(par[num]);}
void mergepar(int a, int b){
a=findpar(a);
b=findpar(b);
if(a==b)return;
if(sz[a]<sz[b])swap(a, b);
vc.eb(b);