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