Submission #595895

#TimeUsernameProblemLanguageResultExecution timeMemory
595895fuad27Parachute rings (IOI12_rings)C++17
0 / 100
750 ms200560 KiB
#include<bits/stdc++.h> using namespace std; const int N = 5010; int n; vector<int> g[N]; vector<vector<int>> v(N, vector<int> (N,0)); void Init(int N_) { n = N_; } void Link(int A, int B) { if(v[A][B])return; g[A].push_back(B); g[B].push_back(A); v[A][B]=1; v[B][A]=1; } int cur; bool check; bool vis[N]; void dfs(int at) { if(vis[at])return; vis[at]=1; int viscnt=0, cnt=0; for(int to:g[at]) { if(vis[to] and to!=cur)viscnt++; else if(to!=cur){ cnt++; dfs(to); } } if(cnt > 1 or viscnt > 1)check=false; vis[at]=1; } int CountCritical() { int ans=0; for(int j = 0;j<n;j++) { cur=j; check=1; for(int i = 0;i<n;i++)vis[i]=0; for(int i = 0;i<n;i++) { if(i == j)continue; int deg=0; for(int j:g[i]) { if(j!=cur)deg++; } if(deg==1){ dfs(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...