Submission #229617

#TimeUsernameProblemLanguageResultExecution timeMemory
229617maruiiParachute rings (IOI12_rings)C++14
20 / 100
4096 ms75368 KiB
#include <bits/stdc++.h> using namespace std; int N, flag, cyc, up[1000005], par[1000005]; vector<int> edge[1000005], ans; int fnd(int x) { return up[x] == x ? x : up[x] = fnd(up[x]); } void Init(int N_) { N = N_; for (int i = 0; i < N; ++i) { up[i] = i; ans.push_back(i); } } void update(int x) { if (edge[x].size() < 3) return; vector<int> v; for (auto i : ans) { if (i == x) v.push_back(i); else if (edge[x].size() < 4) for (auto j : edge[x]) if (i == j) { v.push_back(i); break; } } ans = v; } void Link(int a, int b) { if (ans.empty()) return; edge[a].push_back(b); edge[b].push_back(a); update(a); update(b); } bool vi[1000005]; int dep[1000005]; void dfs(int x, int p) { vi[x] = 1; for (auto i : edge[x]) if (i != p) { if (vi[i]) { if (dep[i] < dep[x]) { vector<int> u, v; u.push_back(i); for (int j = fnd(x); j != fnd(i); j = fnd(par[j])) { up[j] = fnd(par[j]); u.push_back(j); } for (auto i : ans) { for (auto j : u) if (i == j) { v.push_back(i); break; } } ans = v; } continue; } par[i] = x; dep[i] = dep[x] + 1; dfs(i, x); } } int CountCritical() { for (int i = 0; i < N; ++i) vi[i] = 0; for (int i = 0; i < N; ++i) if (!vi[i]) { dep[i] = 0; dfs(i, i); } return ans.size(); }
#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...