Submission #419001

#TimeUsernameProblemLanguageResultExecution timeMemory
419001VladMCop and Robber (BOI14_coprobber)C++14
0 / 100
0 ms328 KiB
#include "coprobber.h" #include <bits/stdc++.h> using namespace std; vector<int> vec[MAX_N]; int dist[MAX_N][MAX_N], pos, vis[MAX_N]; queue<int> q; 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(A[i][j]) vec[i].push_back(j); } } for(int i=0; i<N; i++) { q.push(i); for(int j=0; j<N; j++) dist[i][j]=MAX_N*MAX_N; dist[i][i]=0; while(!q.empty()) { int v=q.front(); q.pop(); int ns=vec[v].size(); for(int j=0; j<ns; j++) { int to=vec[v][j]; if(dist[i][v]+1<dist[i][to]) { dist[i][to]=dist[i][v]+1; q.push(to); } } } } pos=0; vis[pos]=1; return 0; } int nextMove(int R) { int ns=vec[pos].size(); int newpos=-1; for(int i=1; i<ns; i++) { int to=vec[pos][i]; if(newpos==-1 && vis[to]==0) { newpos=to; continue; } if(dist[to][R]<dist[newpos][R] && vis[to]==0) newpos=to; } vis[newpos]=1; return newpos; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...