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>
#include "game.h"
using namespace std;
const int maxn = 1600;
int s[maxn][maxn], parent[maxn];
int n;
void initialize(int N) {
for(int i=0;i<N;i++) {
parent[i] = i;
for(int j=0;j<N;j++) s[i][j] = 1;
s[i][i] = 0;
}
n = N;
}
void unite(int u, int v) {
if(u > v) swap(u, v);
for(int i=0;i<n;i++) {
s[u][i] = s[i][u] = s[u][i] + s[v][i];
}
for(int i=0;i<n;i++) {
if(parent[i] == v) parent[i] = u;
}
}
int hasEdge(int u, int v) {
u = parent[u];
v = parent[v];
if(s[u][v] == 1) {
unite(u, v);
return 1;
}
else {
s[u][v]--;
s[v][u]--;
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... |