Submission #418663

#TimeUsernameProblemLanguageResultExecution timeMemory
418663VladMCop and Robber (BOI14_coprobber)C++14
16 / 100
144 ms262148 KiB
#include "coprobber.h" #include <bits/stdc++.h> using namespace std; vector<int> vec[MAX_N]; int tin[MAX_N], tout[MAX_N], timer, pos, par[MAX_N]; void dfs(int v, int p) { tin[v]=++timer; par[v]=p; int ns=vec[v].size(); for(int i=0; i<ns; i++) { int to=vec[v][i]; if(to==p) continue; dfs(to, v); } tout[v]=timer; return; } 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(j==i) continue; if(A[i][j]) vec[i].push_back(j); } } dfs(0, -1); pos=0; return 0; } int nextMove(int R) { int ns=vec[pos].size(); for(int i=0; i<ns; i++) { int to=vec[pos][i]; if(to==par[pos]) continue; if(tin[to]<=tin[R] && tout[R]<=tout[to]) { pos=to; return to; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...