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;
#define maxn 1505
int n;
int head[maxn];
int way[maxn][maxn];
int temp[maxn];
int findhead(int x) {
if(head[x]==x) return x;
return head[x] = findhead(head[x]);
}
void initialize(int N) {
int i,j;
n = N;
for(i=0;i<n;i++) head[i] = i;
for(i=0;i<n;i++) for(j=0;j<n;j++) way[i][j] = 1;
}
int hasEdge(int u, int v) {
u = findhead(u); v = findhead(v);
if(u==v) return 0;
if(way[u][v]==1) {
for(int i=0;i<n;i++) temp[i] = way[u][i] + way[v][i];
head[findhead(v)] = findhead(u);
for(int i=0;i<n;i++) way[findhead(u)][i] = way[i][findhead(u)] = temp[i];
return 1;
}
else {
way[u][v]--; way[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... |