Submission #143315

#TimeUsernameProblemLanguageResultExecution timeMemory
143315SortingCop and Robber (BOI14_coprobber)C++14
Compilation error
0 ms0 KiB
#include "coprobber.h" #include <bits/stdc++.h> pair<int, short> dp[MAX_N][MAX_N][2]; bool *a; int n; int solve(int cop, int robber, bool turn){ pair<int, short> &p = dp[cop][robber][turn]; if(cop == robber){ if(!turn){ return cop; } else{ return -1; } } if(dp.second == 2){ return dp.first; } if(dp.second == 1){ if(!turn){ return -1; } else{ return robber; } } dp.second = 1; dp.first = -1; if(!turn){ for(int i = 0; i < n; i++){ if(a[i][cop] || i == cop){ int curr = solve(i, robber, !turn); if(curr == -1){ dp.first = i; dp.second = 2; return dp.first; } } } } else{ for(int i = 0; i < n; i++){ if(a[i][robber]){ int curr = solve(cop, i, !turn); if(curr == -1){ dp.first = i; dp.second = 2; return dp.first; } } } } dp.second = 2; return dp.first; } int cop; int start(int N, bool A[MAX_N][MAX_N]){ a = A; n = N; for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j){ solve(i, j, 0); } } int sol = -1; for(int i = 0; i < n; i++){ bool ok = true; for(int j = 0; j < n; j++){ if(solve(i, j, 0) == -1){ ok = false; return; } } if(ok){ sol = i; } } cop = sol; return sol; } int nextMove(int R){ cop = dp[cop][R][0]; return cop; }

Compilation message (stderr)

coprobber.cpp:4:1: error: 'pair' does not name a type; did you mean 'wait'?
 pair<int, short> dp[MAX_N][MAX_N][2];
 ^~~~
 wait
coprobber.cpp: In function 'int solve(int, int, bool)':
coprobber.cpp:9:2: error: 'pair' was not declared in this scope
  pair<int, short> &p = dp[cop][robber][turn];
  ^~~~
coprobber.cpp:9:2: note: suggested alternative:
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from coprobber.cpp:2:
/usr/include/c++/7/bits/stl_pair.h:198:12: note:   'std::pair'
     struct pair
            ^~~~
coprobber.cpp:9:7: error: expected primary-expression before 'int'
  pair<int, short> &p = dp[cop][robber][turn];
       ^~~
coprobber.cpp:19:5: error: 'dp' was not declared in this scope
  if(dp.second == 2){
     ^~
coprobber.cpp:22:5: error: 'dp' was not declared in this scope
  if(dp.second == 1){
     ^~
coprobber.cpp:31:2: error: 'dp' was not declared in this scope
  dp.second = 1;
  ^~
coprobber.cpp:36:15: error: invalid types 'bool[int]' for array subscript
    if(a[i][cop] || i == cop){
               ^
coprobber.cpp:49:18: error: invalid types 'bool[int]' for array subscript
    if(a[i][robber]){
                  ^
coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:68:9: error: cannot convert 'bool (*)[500]' to 'bool*' in assignment
     a = A;
         ^
coprobber.cpp:84:8: error: return-statement with no value, in function returning 'int' [-fpermissive]
        return;
        ^~~~~~
coprobber.cpp: In function 'int nextMove(int)':
coprobber.cpp:99:8: error: 'dp' was not declared in this scope
  cop = dp[cop][R][0];
        ^~