Submission #1121125

#TimeUsernameProblemLanguageResultExecution timeMemory
1121125PagodePaivaCop and Robber (BOI14_coprobber)C++17
0 / 100
1 ms504 KiB
#include<bits/stdc++.h> #include "coprobber.h" using namespace std; const int MAXN = 510; vector <int> g[MAXN]; vector <pair <int, int>> backedges; int pai[MAXN]; int h[MAXN]; void dfs(int v, int p){ pai[v] = p; for(auto x : g[v]){ if(x == p) continue; if(pai[x] != -1){ backedges.push_back({x, v}); continue; } h[x] = h[v]+1; dfs(x, v); } return; } int start(int n, bool a[MAX_N][MAX_N]){ memset(pai, -1, sizeof pai); for(int i = 0;i < n;i++){ for(int j = 0;j < n;j++){ if(a[i][j]) g[i].push_back(j); } } dfs(1, 1); for(auto [a, b] : backedges){ if(h[a] > h[b]) swap(a, b); int con = 2; while(b != a){ if(pai[b] == a) break; if(con > 4) break; set <int> s; int t = b; while(t != a){ s.insert(t); t = pai[t]; } s.insert(a); int minalt = 1e9, ver = -1; for(auto x : g[b]){ if(s.find(x) == s.end()) continue; if(x == a) continue; if(minalt > h[x]){ ver = x; minalt = min(minalt, h[x]); } } con++; b = ver; } if(con > 4){ return -1; } } return 0; } int nextMove(int R){ return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...