Submission #988611

#TimeUsernameProblemLanguageResultExecution timeMemory
988611huutuanParachute rings (IOI12_rings)C++14
20 / 100
4025 ms8664 KiB
#include <bits/stdc++.h> using namespace std; struct DSU{ int n; vector<int> lab; void init(int _n){ n=_n; lab.assign(n+1, -1); } int find_set(int u){ return lab[u]<0?u:lab[u]=find_set(lab[u]); } bool union_sets(int u, int v){ u=find_set(u); v=find_set(v); if (u!=v){ if (lab[u]>lab[v]) swap(u, v); lab[u]+=lab[v]; lab[v]=u; return 1; } return 0; } } dsu; const int N=1e6+10; int n, deg[N]; vector<pair<int, int>> edge; bool check; void Init(int N_) { n=N_; } void build(int u){ for (int i=1; i<=n; ++i) deg[i]=0; check=1; dsu.init(n); for (auto &i:edge){ if (i.first==u || i.second==u) continue; ++deg[i.first]; ++deg[i.second]; check&=deg[i.first]<=2 && deg[i.second]<=2; check&=dsu.union_sets(i.first, i.second); } } void Link(int u, int v) { ++u; ++v; edge.emplace_back(u, v); } int CountCritical() { int ans=0; for (int i=1; i<=n; ++i) build(i), ans+=check; 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...