Submission #90190

#TimeUsernameProblemLanguageResultExecution timeMemory
90190nikolapesic2802Cop and Robber (BOI14_coprobber)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "coprobber.h" using namespace std; #define pb push_back int lim=MAX_N*MAX_N; vector<vector<int> > graf(2*lim); vector<vector<int> > graph(MAX_N); int convert(int i,int j,int k) { int br=i+j*MAX_N+k*lim; return br; } vector<int> winlose(2*lim); vector<int> dosada(2*lim); vector<int> visited(2*lim); int dfs(int tr) { //printf("Usao za %i\n",tr); visited[tr]=1; assert(winlose[tr]==0); if(tr>=lim) { for(auto p:graf[tr]) { if(winlose[p]==1) continue; if(visited[p]) return -1; int val=dfs(p); if(val==-1) return -1; } return 1; } else { for(auto p:graf[tr]) { if(winlose[p]==1) return p; if(visited[p]) continue; int val=dfs(p); if(val!=-1) return p; } return -1; } } int pozicija=0; int start(int N, bool A[MAX_N][MAX_N]) { for(int i=0;i<N;i++) for(int j=0;j<N;j++) if(i!=j) assert(a[i][j]); for(int i=0;i<N;i++) for(int j=0;j<N;j++) if(A[i][j]) graph[i].pb(j); for(int i=0;i<N;i++) { for(int j=0;j<N;j++) { if(i==j) { winlose[convert(i,j,0)]=1; winlose[convert(i,j,1)]=1; continue; } //printf("%i %i %i->%i %i %i: %i->%i\n",i,j,0,i,j,1,convert(i,j,0),convert(i,j,1)); graf[convert(i,j,0)].pb(convert(i,j,1)); for(auto p:graph[i]) { //printf("%i %i %i->%i %i %i: %i->%i\n",i,j,0,p,j,1,convert(i,j,0),convert(p,j,1)); graf[convert(i,j,0)].pb(convert(p,j,1)); } for(auto p:graph[j]) { //printf("%i %i %i->%i %i %i: %i->%i\n",i,j,1,i,p,0,convert(i,j,1),convert(i,p,0)); graf[convert(i,j,1)].pb(convert(i,p,0)); } } } bool test=true; for(int i=1;i<N;i++) { fill(visited.begin(),visited.end(),0); if(dfs(convert(0,i,0))==-1) test=false; } if(test) return 0; return -1; } int convert_back(int tr) { while(tr>=lim) tr-=lim; while(tr>=MAX_N) tr-=MAX_N; return tr; } int nextMove(int R) { visited=dosada; //printf("Trenutna pozicija: %i ",pozicija); pozicija=convert_back(dfs(convert(pozicija,R,0))); //printf("%i, idem na polje %i.\n",R,pozicija); dosada[convert(pozicija,R,0)]=1; return pozicija; }

Compilation message (stderr)

In file included from /usr/include/c++/7/cassert:44:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from coprobber.cpp:1:
coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:57:24: error: 'a' was not declared in this scope
                 assert(a[i][j]);
                        ^