이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int cnt[1501][1501];
int n, p[1501], sz[1501], vis[1501];
int findSet(int i){return i==p[i]?i:p[i]=findSet(p[i]);}
int unionSet(int x, int y){
if(sz[x]>sz[y]) swap(x,y);
fill(vis,vis+n,0); p[y] = x; sz[x]+=sz[y];
for(int i = 0; i < n; i++){
int z = findSet(i);
if(vis[z]) continue; vis[z]=1;
cnt[z][x] = cnt[x][z]+cnt[y][z];
cnt[x][z] = cnt[x][z]+cnt[y][z];
}
return 1;
}
void initialize(int N){
n = N; fill(sz,sz+n,1);
for(int i = 0; i < n; p[i]=i, i++)
for(int j = 0; j < n; j++) cnt[i][j]=(i!=j);
}
int hasEdge(int u, int v){
int x = findSet(u), y = findSet(v);
return cnt[x][y]==1?unionSet(x,y):0*cnt[x][y]--;
}
컴파일 시 표준 에러 (stderr) 메시지
game.cpp: In function 'int unionSet(int, int)':
game.cpp:13:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
13 | if(vis[z]) continue; vis[z]=1;
| ^~
game.cpp:13:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
13 | if(vis[z]) continue; vis[z]=1;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |