제출 #590580

#제출 시각아이디문제언어결과실행 시간메모리
590580Dan4Life게임 (IOI14_game)C++17
0 / 100
1 ms304 KiB
#include <bits/stdc++.h>
#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], cnt2[maxn], ind=0, n; bool ok = false;
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; ok=1;
    cnt2[i]++; if(sz[x]<sz[y]) swap(x,y);
    p[y] = x; sz[x]+=sz[y]; return 1;
}

void initialize(int N) {
    n = N;
    for(int i = 0; i <= n; i++) 
        p[i]=-1,sz[i]=1,cnt[i]=cnt2[i]=0;
}

int hasEdge(int u, int v) {
    u++, v++; cnt[u]++, cnt[v]++;
    return (cnt[u]==n-1 or cnt[v]==n-1); 
    if(isSameSet(u,v)) return 0;
    if(isSameSet(u,0)) swap(u,v); 
    if(!ok and (cnt[u]==n-1 or cnt[v]==n-1)) 
        return unionSet(u,0),unionSet(v,0);
    if(!ok) return 0; 
    cout << cnt2[3] << ": ";
    if(cnt2[u]==sz[findSet(0)]-1) return 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 unionSet(int, int)':
game.cpp:16:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   16 |     if(x==y) return 0; ok=1;
      |     ^~
game.cpp:16:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   16 |     if(x==y) return 0; ok=1;
      |                        ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...