제출 #590549

#제출 시각아이디문제언어결과실행 시간메모리
590549Dan4Life게임 (IOI14_game)C++17
0 / 100
0 ms312 KiB
#include <bits/stdc++.h> //#define LOL #if !defined(LOL) #include "game.h" #endif using namespace std; #define pb push_back #define all(a) a.begin(),a.end() #define ll long long const int maxn = 1510; int p[maxn], sz[maxn], cnt[maxn], edge[maxn][maxn], ind = 0; int findSet(int i){return p[i]==-1?i:p[i]=findSet(p[i]);} bool isSameSet(int i, int j){return findSet(i)==findSet(j);} int unionSet(int i, int j){ int x = findSet(i), y = findSet(j); if(x==y) return 0; if(sz[x]<sz[y]) swap(x,y); p[y] = x; sz[x]+=sz[y]; return 1; } void initialize(int n) { for(int i = 0; i <= n; i++) p[i]=-1,sz[i]=1,cnt[i]=0; } int hasEdge(int u, int v) { u++, v++; if(edge[u][v] or edge[v][u]) return 1; if(isSameSet(u,v)) return 0; if(!isSameSet(u,0) and !isSameSet(v,0)) return 0; if(isSameSet(u,0)) swap(u,v); cnt[u]++; if(cnt[u]==sz[findSet(0)]) return edge[u][v]=edge[v][u]=unionSet(u,0); return 0; } #if defined(LOL) int read_int() { int x; assert(scanf("%d", &x) == 1); return x; } int main() { int n, u, v; n = read_int(); initialize(n); for (int i = 0; i < n * (n - 1) / 2; i++) { u = read_int(); v = read_int(); printf("%d\n", hasEdge(u, v)); } return 0; } #endif

컴파일 시 표준 에러 (stderr) 메시지

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:32:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   32 |     if(isSameSet(u,0)) swap(u,v); cnt[u]++;
      |     ^~
game.cpp:32:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   32 |     if(isSameSet(u,0)) swap(u,v); cnt[u]++;
      |                                   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...