이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
int dsu[1505];
int cnt[1505][1505];
int N;
int find(int x) {
if(dsu[x]==x) return x;
return dsu[x] = find(dsu[x]);
}
void initialize(int n) {
N = n;
for(int i=0; i<n; i++) dsu[i] = i;
for(int i=0; i<n; i++) {
for(int j=i+1; j<n; j++) {
cnt[i][j] = 1;
}
}
}
int hasEdge(int u, int v) {
int x = find(u), y = find(v);
if(cnt[min(x, y)][max(x, y)] == 1) {
for(int i=0; i<N; i++) {
cnt[min(i, y)][max(i, y)] += cnt[min(i, x)][max(i, x)];
}
for(int i=0; i<N; i++) {
cnt[min(i, x)][max(i, x)] = 0;
}
dsu[x] = y;
return 1;
}
cnt[min(x, y)][max(x, y)]--;
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... |