Submission #38539

#TimeUsernameProblemLanguageResultExecution timeMemory
38539WaschbarCop and Robber (BOI14_coprobber)C++14
16 / 100
230 ms262144 KiB
#include <bits/stdc++.h> #include "coprobber.h" //using namespace std; //const int MAX_N = 15; int n, s, timer; int p[1000], tin[1000], tout[1000]; bool ind; bool g[1000][1000]; bool used[1000]; void DFS(int f, int pr) { p[f] = pr; tin[f] = ++timer; used[f] = 1; for(int i = 0; i < n; i++) { if(!g[f][i] || i == pr) continue; if(used[i]) ind = 1; DFS(i,f); } tout[f] = timer; } bool upper(int x, int y) { //cout << x << " - " << tin[x] << " " << tout[x] << " | " << y << " - " << tin[y] << " " << tout[y] << endl; return ((tin[x] <= tin[y]) && (tout[x] >= tout[y])); } int start(int N, bool A[MAX_N][MAX_N]) { n = N; s = 0; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) g[i][j] = A[i][j]; DFS(0, -1); if(ind) return -1; return 0; } int nextMove(int R) { for(int i = 0; i < n; i++) { //cout << s << " " << i << " " << g[s][i] << endl; if(!g[s][i] || i == p[s]) continue; if(upper(i,R)) {s = i; return i;} } return -1; } /* bool v[MAX_N][MAX_N]; int main() { int nn; cin >> nn; for(int i = 1; i < nn; i++) { int x, y; cin >> x >> y; v[x][y] = v[y][x] = 1; } cout << ":: " << start(nn,v) << endl; while(true){ int x; cin >> x; cout <<":: " << nextMove(x) << endl; } }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...