Submission #961349

#TimeUsernameProblemLanguageResultExecution timeMemory
961349berrCop and Robber (BOI14_coprobber)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; int pos; int val[505][505][2]; int vis[505][505][2]; int b[505][505], c[505][505]; int start(int n, bool a[MAX_N][MAX_N]) { vector<array<int, 2>> b; vector<int> g[n]; for(int i=0; i<n; i++){ for(int l=0; l<n; l++){ if(a[i][l]){ g[i].push_back(l); } } } vector<array<int, 3>> q; for(int i=0; i<n; i++){ val[i][i][0]=1; val[i][i][1]=0; q.push_back({i, i, 1}); q.push_back({i, i, 1}); } while(pos<q.size()){ auto [x, y, z]=q[pos]; if(vis[x][y][z]) pos++, continue; vis[x][y][z]=1; if(z==0){ if(val[x][y][z]==1) for(auto i: g[y]){ c[x][i]++; if(c[x][i]==g[i].size()){ q.push_back({x, i, 1}); } } } else { for(auto i: g[x]){ b[i][y]=x; q.push_back({i, y, 0}); } b[x][y]=x; q.push_back({x, y, 0}); } pos++; } for(int i=0; i<n; i++){ int flag=1; for(int j=0; j<n; j++){ if(val[i][j][0]==0){ flag=0; } } if(flag){ return pos=i; } } return -1; } int nextMove(int R) { return pos=b[pos][R]; }

Compilation message (stderr)

coprobber.cpp:11:25: error: 'MAX_N' was not declared in this scope
   11 | int start(int n, bool a[MAX_N][MAX_N]) {
      |                         ^~~~~
coprobber.cpp:11:32: error: 'MAX_N' was not declared in this scope
   11 | int start(int n, bool a[MAX_N][MAX_N]) {
      |                                ^~~~~
coprobber.cpp: In function 'int start(...)':
coprobber.cpp:14:19: error: 'n' was not declared in this scope
   14 |     vector<int> g[n];
      |                   ^
coprobber.cpp:18:16: error: 'a' was not declared in this scope
   18 |             if(a[i][l]){
      |                ^
coprobber.cpp:19:17: error: 'g' was not declared in this scope
   19 |                 g[i].push_back(l);
      |                 ^
coprobber.cpp:35:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     while(pos<q.size()){
      |           ~~~^~~~~~~~~
coprobber.cpp:37:33: error: expected primary-expression before 'continue'
   37 |         if(vis[x][y][z]) pos++, continue;
      |                                 ^~~~~~~~
coprobber.cpp:42:25: error: 'g' was not declared in this scope
   42 |             for(auto i: g[y]){
      |                         ^
coprobber.cpp:45:42: error: no matching function for call to 'std::vector<std::array<int, 3> >::push_back(<brace-enclosed initializer list>)'
   45 |                     q.push_back({x, i, 1});
      |                                          ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from coprobber.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; std::vector<_Tp, _Alloc>::value_type = std::array<int, 3>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::array<int, 3>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; std::vector<_Tp, _Alloc>::value_type = std::array<int, 3>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::array<int, 3> >::value_type&&' {aka 'std::array<int, 3>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
coprobber.cpp:50:25: error: 'g' was not declared in this scope
   50 |             for(auto i: g[x]){
      |                         ^
coprobber.cpp:52:38: error: no matching function for call to 'std::vector<std::array<int, 3> >::push_back(<brace-enclosed initializer list>)'
   52 |                 q.push_back({i, y, 0});
      |                                      ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from coprobber.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; std::vector<_Tp, _Alloc>::value_type = std::array<int, 3>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::array<int, 3>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; std::vector<_Tp, _Alloc>::value_type = std::array<int, 3>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::array<int, 3> >::value_type&&' {aka 'std::array<int, 3>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~