Submission #375623

#TimeUsernameProblemLanguageResultExecution timeMemory
375623Alex_tz307Game (IOI14_game)C++17
Compilation error
0 ms0 KiB
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 (stderr)

game.cpp: In function 'void unite(int, int)':
game.cpp:12:9: error: 'swap' was not declared in this scope
   12 |         swap(u, v);
      |         ^~~~
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:39:11: error: 'x' was not declared in this scope
   39 |     unite(x, y);
      |           ^
game.cpp:39:14: error: 'y' was not declared in this scope
   39 |     unite(x, y);
      |              ^