Submission #1092227

#TimeUsernameProblemLanguageResultExecution timeMemory
1092227codexistentGame (IOI14_game)C++14
Compilation error
0 ms0 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = a; i <= b; i++) int p[1505], edge[1505 * 1505]; set<int> adj[1505]; int cc(int a, int b){ return a * 10000 + b; } int fc(int x){ return x / 10000; } int sc(int x){ return x % 10000; } int find(int x){ return (p[x] == x) ? x : (p[x] = find(p[x])); } void onion(int a, int b){ a = find(a), b = find(b); if(a == b) return; if(adj[a].size() < adj[b].size()) swap(a, b); for(int i : adj[b]){ adj[a].insert(i); int x = find(fc(i)), y = find(sc(i)); if(y == b) swap(x, y); edge[min(a, y)][max(a, y)]++; edge[min(b, y)][max(b, y)]--; // cout << " WE ONLY MERGED EDGE " << i.first << " TO " << i.second << ", ERASED FROM " << b << ", " << y << " AND ADDED TO " << a << ", " << y << endl; } adj[b].clear(); p[a] = p[b] = a; } void initialize(int n) { FOR(i, 0, n - 1) p[i] = i; FOR(i, 0, n - 1){ FOR(j, i + 1, n - 1){ adj[i].insert(cc(i, j)); adj[j].insert(cc(i, j)); edge[i][j] = 1; } } } int hasEdge(int u, int v) { int e = cc(min(u, v), max(u, v)); u = find(u), v = find(v); adj[u].erase(e); adj[v].erase(e); edge[min(u, v)][max(u, v)]--; if(u == v) return 1; if(edge[min(u, v)][max(u, v)] == 0){ onion(u, v); return 1; } return 0; }

Compilation message (stderr)

game.cpp: In function 'void onion(int, int)':
game.cpp:28:24: error: invalid types 'int[const int]' for array subscript
   28 |         edge[min(a, y)][max(a, y)]++;
      |                        ^
game.cpp:29:24: error: invalid types 'int[const int]' for array subscript
   29 |         edge[min(b, y)][max(b, y)]--;
      |                        ^
game.cpp: In function 'void initialize(int)':
game.cpp:44:20: error: invalid types 'int[int]' for array subscript
   44 |             edge[i][j] = 1;
      |                    ^
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:55:20: error: invalid types 'int[const int]' for array subscript
   55 |     edge[min(u, v)][max(u, v)]--;
      |                    ^
game.cpp:58:23: error: invalid types 'int[const int]' for array subscript
   58 |     if(edge[min(u, v)][max(u, v)] == 0){
      |                       ^