답안 #375625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
375625 2021-03-09T15:43:09 Z Alex_tz307 게임 (IOI14_game) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

const int NMAX = 1505;
int N, p[NMAX], sz[NMAX], cnt[NMAX][NMAX];
 
int get(int x) {
    if(x == p[x])
        return x;
    return p[x] = get(p[x]);
}
 
void unite(int u, int v) {
    if(sz[u] < sz[v])
        swap(u, v);
    for(int k = 1; k <= N; ++k) 
        cnt[u][k] += cnt[v][k], cnt[k][u] += cnt[v][k];
    p[v] = u;
}
 
void initialize(int n) {
    N = n;
    for(int i = 1; i <= N; ++i) {
        p[i] = i;
        sz[i] = 1;
        for(int j = 1; j <= N; ++j)
            if(i != j)
                cnt[i][j] = 1;
    }
}
 
int hasEdge(int u, int v) {
    ++u, ++v;
    u = get(u);
    v = get(v);
    if(u == v)
        return 0;
    if(cnt[u][v] > 1) {
        --cnt[u][v], --cnt[v][u];
        return 0;
    }
    unite(x, y);
    return 1;
}

Compilation message

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:43:11: error: 'x' was not declared in this scope
   43 |     unite(x, y);
      |           ^
game.cpp:43:14: error: 'y' was not declared in this scope
   43 |     unite(x, y);
      |              ^