이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "game.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int noedge[1515][1515], sz[1515], path[1515], h[1515], N;
int dis_find(int s){
if (s==path[s]) return s;
return path[s]=dis_find(path[s]);
}
void dis_merge(int s1, int s2){
int v1=dis_find(s1), v2=dis_find(s2);
if (h[v1]>h[v2]) swap(v1, v2);
path[v1]=v2;
if (h[v1]==h[v2]) h[v2]++;
sz[v2] += sz[v1];
for (int i=0;i<N;i++){
noedge[v2][i] += noedge[v1][i];
noedge[i][v2] += noedge[i][v1];
}
}
void initialize(int n) {
N=n;
for (int i=0;i<N;i++){
sz[i]=1;
path[i]=i;
}
}
int hasEdge(int u, int v) {
int x=dis_find(u), y=dis_find(v);
assert(x!=y);
if (sz[x]*sz[y]-1==noedge[x][y]){
dis_merge(x, y);
return 1;
}
noedge[x][y]++, noedge[y][x]++;
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... |