#include "game.h"
int con[1501][1501];
int siz[1501];
int rep[1501];
int N;
int findrep(int n) {
while(n!=rep[n]) n = rep[n];
return n;
}
void initialize(int n) {
N = n;
for(int i=0; i<=n; i++) {
siz[i] = 1;
rep[i] = i;
}
}
int hasEdge(int u, int v) {
int x = findrep(u);
int y = findrep(v);
if(con[x][y] != siz[x]*siz[y]-1) {
con[x][y]++;
con[x][y]++;
return 0;
}
//merge u and v
rep[y] = x;
siz[x]+=siz[y];
for (int i = 0; i < N; ++i) con[x][i]+=con[y][i];
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
18716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
18716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
18716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |