Submission #1009133

#TimeUsernameProblemLanguageResultExecution timeMemory
1009133RifalParachute rings (IOI12_rings)C++14
20 / 100
4019 ms860 KiB
#include <bits/stdc++.h> //#include "rings.h" using namespace std; const int N = 5e3 + 5; int n; vector<int> v[N]; bool vis[N], ok; int deg[N], nod; void dfs(int s, int p) { vis[s] = 1; if(deg[s] > 2) ok = false; for(auto i : v[s]) { if(i != p && i != nod) { if(vis[i] == 0) { dfs(i,s); } else { ok = false; } } } } void Init(int N_) { n = N_; } void Link(int A, int B) { deg[A]++; deg[B]++; v[A].push_back(B); v[B].push_back(A); } int CountCritical() { int sol = 0; for(int i = 0; i < n; i++) { nod = i; ok = true; for(auto j : v[i]) deg[j]--; for(int j = 0; j < n; j++) vis[j] = 0; for(int j = 0; j < n; j++) { if(vis[j] == 0 && j != nod) { dfs(j,-1); } } if(ok) sol++; for(auto j : v[i]) deg[j]++; } return sol; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...