Submission #1035189

#TimeUsernameProblemLanguageResultExecution timeMemory
103518912345678Parachute rings (IOI12_rings)C++17
37 / 100
998 ms120980 KiB
#include <bits/stdc++.h> using namespace std; const int nx=1e6+5; int n, vs[nx], sm[nx], rem[nx], cnt, res, lvl[nx], t; vector<int> d[nx]; void dfs(int u, int p) { vs[u]=1; lvl[u]=lvl[p]+1; for (auto v:d[u]) { if (v==p) continue; if (!vs[v]) dfs(v, u); else if (lvl[v]<lvl[u]) sm[u]++, rem[v]++, cnt++; } } void dfs2(int u, int p) { vs[u]=1; for (auto v:d[u]) if (v!=p&&!vs[v]) dfs2(v, u), sm[u]+=sm[v]-rem[v]; if (sm[u]==cnt) { int f=0, tmp=d[u].size()>2; for (auto v:d[u]) { if (d[v].size()>3) f=1; else if (d[v].size()==3) tmp++; } if (!f&&tmp==t) res++; } } void Init(int N_) { n=N_; } void Link(int A, int B) { d[A].push_back(B), d[B].push_back(A); } int CountCritical() { cnt=res=t=0; for (int i=0; i<n; i++) vs[i]=sm[i]=rem[i]=0, t+=d[i].size()>2; for (int i=0; i<n; i++) if (!vs[i]) dfs(i, i); for (int i=0; i<n; i++) vs[i]=0; for (int i=0; i<n; i++) if (!vs[i]) dfs2(i, i); return res; }
#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...