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 "game.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll p[1505],sz[1505],q[1505];
ll lider(ll a) {
if (p[a]==a) return a;
p[a] = lider(p[a]);
return p[a];
}
void unir(ll a, ll b) {
if (sz[b]>sz[a]) swap(a,b);
p[b] = a;
sz[a] += sz[b];
q[a] += q[b];
return;
}
void initialize(int n) {
ll i;
for (i=0;i<n;i++) {
p[i] = i;
sz[i] = 1;
q[i] = n-1;
}
}
int hasEdge(int u, int v) {
if (q[lider(u)]==1 || q[lider(v)]==1) {
q[lider(u)]--; q[lider(v)]--;
unir(lider(u),lider(v));
return 1;
}
else {
q[lider(u)]--; q[lider(v)]--;
return 0;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |