Submission #959141

#TimeUsernameProblemLanguageResultExecution timeMemory
959141berrCop and Robber (BOI14_coprobber)C++17
Compilation error
0 ms0 KiB
int pos; map<array<int, 2>, int> mp; int state[500][500][2]; vector<vector<int>> g(500); int calc(int x, int y, int player){ if(x==y&&player==0) return state[x][y][player]=x; else if(x==y)return state[x][y][player]=-1; if(state[x][y][player]!=-2)return state[x][y][player]; if(player==0){ int c=0; state[x][y][player]=-1; //-1 means holding for(auto i: g[x]){ if(calc(i, y, 1)==-1){ state[x][y][0]=i; c++; } } if(calc(x, y, 1)==-1){ state[x][y][0]=x; c++; } if(!c) state[x][y][player]=-1; } else{ int c=0; state[x][y][player]=0; for(auto i: g[y]){ if(calc(x, i, 0)==-1){ state[x][y][1]=i; c++; } } if(!c){ state[x][y][player]=-1; for(auto i: g[x]){ for(auto l: g[y]) state[i][l][0]=x; } for(auto l: g[y]) state[x][l][0]=x; } } return state[x][y][player]; }; int start(int n, bool a[MAX_N][MAX_N]) { for(int i=0; i<n; i++){ for(int l=0; l<n; l++){ state[i][l][0]=-2; state[i][l][1]=-2; if(a[i][l]){ g[i].push_back(l); } } } for(int i=0; i<n; i++){ int flag=1; for(int l=0; l<n; l++){ if(calc(i, l, 1)!=-1){ flag=0; } } if(flag) return pos=i; } return -1; } int nextMove(int R) { return pos = calc(pos, R, 0); }

Compilation message (stderr)

coprobber.cpp:2:1: error: 'map' does not name a type
    2 | map<array<int, 2>, int> mp;
      | ^~~
coprobber.cpp:4:1: error: 'vector' does not name a type
    4 | vector<vector<int>> g(500);
      | ^~~~~~
coprobber.cpp: In function 'int calc(int, int, int)':
coprobber.cpp:16:21: error: 'g' was not declared in this scope
   16 |         for(auto i: g[x]){
      |                     ^
coprobber.cpp:35:21: error: 'g' was not declared in this scope
   35 |         for(auto i: g[y]){
      |                     ^
coprobber.cpp:44:25: error: 'g' was not declared in this scope
   44 |             for(auto i: g[x]){
      |                         ^
coprobber.cpp:48:30: error: 'g' was not declared in this scope
   48 |                  for(auto l: g[y])
      |                              ^
coprobber.cpp: At global scope:
coprobber.cpp:57:25: error: 'MAX_N' was not declared in this scope
   57 | int start(int n, bool a[MAX_N][MAX_N]) {
      |                         ^~~~~
coprobber.cpp:57:32: error: 'MAX_N' was not declared in this scope
   57 | int start(int n, bool a[MAX_N][MAX_N]) {
      |                                ^~~~~
coprobber.cpp: In function 'int start(...)':
coprobber.cpp:60:20: error: 'n' was not declared in this scope
   60 |     for(int i=0; i<n; i++){
      |                    ^
coprobber.cpp:64:16: error: 'a' was not declared in this scope
   64 |             if(a[i][l]){
      |                ^
coprobber.cpp:65:17: error: 'g' was not declared in this scope
   65 |                 g[i].push_back(l);
      |                 ^
coprobber.cpp:70:20: error: 'n' was not declared in this scope
   70 |     for(int i=0; i<n; i++){
      |                    ^