Submission #395065

#TimeUsernameProblemLanguageResultExecution timeMemory
395065Nicholas_Patrick경찰관과 강도 (BOI14_coprobber)C++17
0 / 100
1 ms328 KiB
#include "coprobber.h" // #include "grader.cpp" #include <cstdio> #include <queue> #include <bitset> #include <algorithm> using namespace std; int cop; bool a[MAX_N][MAX_N]; vector<int> adjLis[MAX_N]; //sub2 int sidelength; vector<vector<int>> solved, cnt; vector<vector<bitset<500>>> run; void solve(int cop, int robber, bool copturn=true){ //calling this function: robber caught if(copturn){ for(int i: adjLis[robber]){ cnt[cop][i]-=run[cop][i][robber]; run[cop][i][robber]=false; if(cnt[cop][i])//no place to run solve(cop, i, false); } }else{ for(int i: adjLis[cop]){ if(solved[i][robber]==-1){ solved[i][robber]=cop; solve(i, robber, true); } } if(solved[cop][robber]==-1){ solved[cop][robber]=cop; solve(cop, robber, true); } } } int start(int n, bool A[MAX_N][MAX_N]){ for(int i=n; i--;)for(int j=n; j--;) a[i][j]=A[i][j]; for(int i=n; i--;)for(int j=n; j--;){ if(a[i][j]) adjLis[i].push_back(j); } solved.assign(n, vector<int>(n, -1)); cnt.assign(n, vector<int>(n)); run.assign(n, vector<bitset<500>>(n)); for(int i=n; i--;)for(int j=n; j--;){ cnt[i][j]=adjLis[j].size(); for(int k=n; k--;) run[i][j][k]=A[j][k]; } for(int i=n; i--;){ solved[i][i]=i; solve(i, i); } for(int i=n; i--;)for(int j: adjLis[i]){ solved[i][j]=j; solve(i, j); } if(*min_element(solved[0].begin(), solved[0].end())>=0) return cop=0; return -1; } int nextMove(int r){ return cop=solved[cop][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...