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;
int br[1501][1501];
vector<int> dsu(1501);
int k;
int calc(int a) {
while(dsu[a] != a) {
a = dsu[a];
}
return a;
}
bool edge(int a, int b) {
int c = calc(a),d = calc(b);
dsu[d] = c;
if(c != d) {
return true;
}
else {
return false;
}
}
void initialize(int n) {
k = n;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
br[i][j] = 1;
}
}
for(int i = 1; i <= n; i++) {
dsu[i] = i;
}
}
int hasEdge(int u, int v) {
int ans,a = calc(u),b = calc(v);
if(br[calc(u)][calc(v)] == 1) {
ans = 1;
edge(a,b);
for(int i = 1; i <= k; i++) {
br[a][i] = br[a][i]+br[b][i];
br[i][a] = br[a][i];
}
}
else {
ans = 0;
br[a][b]--;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |