Submission #659050

#TimeUsernameProblemLanguageResultExecution timeMemory
659050Danilo21Game (IOI14_game)C++14
Compilation error
0 ms0 KiB
#include "game.h"
#include <vector>

const mxN = 1510;
int N, f[mxN], cnt[mxN][mxN];

int Find(int s){
    if (f[s] == s) return s;
    return f[s] = Find(f[s]);
}

bool Union(int u, int v){

    u = Find(u); v = Find(v);
    cnt[u][v]--;
    cnt[v][u]--;
    if (!cnt[u][v]){
        for (int i = 0; i < N; i++){
            cnt[u][i] += cnt[v][i];
            cnt[i][u] += cnt[i][v];
        }
        f[v] = u;
        return 1;
    }
    return 0;
}

void initialize(int n){

    N = n;
    for (int i = 0; i < N; i++){
        f[i] = i;
        for (int j = 0; j < N; j++)
            if (i^j) cnt[i][j] = 1;
    }
}

int hasEdge(int u, int v){ return Union(u, v); }

Compilation message (stderr)

game.cpp:4:7: error: 'mxN' does not name a type
    4 | const mxN = 1510;
      |       ^~~
game.cpp:5:10: error: 'mxN' was not declared in this scope
    5 | int N, f[mxN], cnt[mxN][mxN];
      |          ^~~
game.cpp:5:20: error: 'mxN' was not declared in this scope
    5 | int N, f[mxN], cnt[mxN][mxN];
      |                    ^~~
game.cpp:5:25: error: 'mxN' was not declared in this scope
    5 | int N, f[mxN], cnt[mxN][mxN];
      |                         ^~~
game.cpp: In function 'int Find(int)':
game.cpp:8:9: error: 'f' was not declared in this scope
    8 |     if (f[s] == s) return s;
      |         ^
game.cpp:9:12: error: 'f' was not declared in this scope
    9 |     return f[s] = Find(f[s]);
      |            ^
game.cpp: In function 'bool Union(int, int)':
game.cpp:15:5: error: 'cnt' was not declared in this scope; did you mean 'int'?
   15 |     cnt[u][v]--;
      |     ^~~
      |     int
game.cpp:22:9: error: 'f' was not declared in this scope
   22 |         f[v] = u;
      |         ^
game.cpp: In function 'void initialize(int)':
game.cpp:32:9: error: 'f' was not declared in this scope
   32 |         f[i] = i;
      |         ^
game.cpp:34:22: error: 'cnt' was not declared in this scope; did you mean 'int'?
   34 |             if (i^j) cnt[i][j] = 1;
      |                      ^~~
      |                      int