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 ll long long
#define forn(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define sz(a) (int)a.size()
const int N = 1600;
bool asked[N][N];
bool know[N][N];
int par[N], s[N];
int n;
int get(int a){
return (a == par[a] ? a : par[a] = get(par[a]));
}
void uni(int a, int b){
a = get(a), b = get(b);
if(s[a] > s[b])swap(a, b);
par[a] = b;
s[b] += s[a];
}
void initialize(int N){
n = N;
for(int i = 0;i < n; ++i){
s[i] = 1;
par[i] = i;
}
}
int hasEdge(int u, int v){
if(s[get(u)] == s[get(v)]){
return 0;
}else{
uni(u, v);
return 1;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |