Submission #1076963

#TimeUsernameProblemLanguageResultExecution timeMemory
1076963ArthuroWichParachute rings (IOI12_rings)C++17
0 / 100
4064 ms10076 KiB
#include<bits/stdc++.h> using namespace std; vector<int> adj[200005], vis; int n, ans = 0; bool f = 1; void Init(int N_) { n = N_; ans = n; } void dfs(int i, int p, int s) { if (vis[i]) { f = 0; return; } vis[i] = 1; for (int j : adj[i]) { if (j == p || j == s) { continue; } dfs(j, i, s); } } int calc(int a) { vis.resize(n, 0); vector<int> co(n, 0); for (int j : adj[a]) { co[j]++; } f = 1; for (int i = 0; i < n; i++) { if (i != a && adj[i].size()-co[i] > 2) { f = 0; break; } if (vis[i] || i == a) { continue; } dfs(i, -1, a); } vis.clear(); return f; } void Link(int A, int B) { adj[A].push_back(B); adj[B].push_back(A); ans = 0; for (int i = 0; i < n; i++) { ans += calc(i); } } int CountCritical() { return ans; }
#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...