Submission #71361

#TimeUsernameProblemLanguageResultExecution timeMemory
71361someone_aaCop and Robber (BOI14_coprobber)C++17
100 / 100
659 ms8312 KiB
#include "coprobber.h" #include <bits/stdc++.h> using namespace std; const int maxn = 510; bool visited[maxn][maxn][2]; bool a[maxn][maxn]; int n; int lf[maxn][maxn][2]; int nxt[maxn][maxn]; struct state { int c, r, t; }; int curr; int start(int N, bool A[MAX_N][MAX_N]) { queue<state>q; for(int r=0;r<N;r++) { int dg = count(A[r], A[r]+N, true); for(int c=0;c<N;c++) { if(c!=r) { lf[c][r][0] = 1; lf[c][r][1] = dg; } } q.push({r,r,0}); q.push({r,r,1}); } int calls = 0; while(!q.empty()) { state curr = q.front(); q.pop(); //if(curr.c == 0) // cout<<curr.c<<" "<<curr.r<<" Last was: "<<curr.t<<" -> \n"; visited[curr.c][curr.r][curr.t] = true; calls++; if(curr.t) { for(int i=0;i<N;i++) { if((i==curr.c || A[curr.c][i]) && lf[i][curr.r][0]) { //if(curr.c == 0) // cout<<"calling: "<<i<<"with state 0"<<"\n"; lf[i][curr.r][0] = 0; q.push({i, curr.r, 0}); nxt[i][curr.r] = curr.c; } } } else { for(int i=0;i<N;i++) { if(A[curr.r][i] && lf[curr.c][i][1]) { //if(curr.c == 0) // cout<<"calling: "<<i<<"with state 1"<<" left: "<<lf[curr.c][i][1]<<"\n"; lf[curr.c][i][1]--; if(lf[curr.c][i][1] == 0) { q.push({curr.c,i,1}); } } } } } if(calls == 2 * N * N) return 0; else return -1; } int nextMove(int R) { return curr = nxt[curr][R]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...