# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
357283 | daniel920712 | Parachute rings (IOI12_rings) | C++14 | 4046 ms | 42768 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
int N;
int who;
vector < int > Next[1000005];
int deg[1000005];
bool have[1000005];
int ok=1;
void Init(int N_)
{
N = N_;
}
void Link(int A, int B)
{
Next[A].push_back(B);
Next[B].push_back(A);
deg[A]++;
deg[B]++;
}
void F(int here)
{
int t=0;
have[here]=1;
for(auto i:Next[here]) if(!have[i]&&i!=who) F(i);
}
int CountCritical()
{
int ans=0;
int i,j;
for(i=0;i<N;i++)
{
ok=1;
who=i;
for(auto j:Next[i])
{
deg[j]--;
if(deg[j]>=3) ok=0;
}
if(ok)
{
for(j=0;j<N;j++) have[j]=0;
have[i]=1;
for(j=0;j<N;j++)
{
if(deg[j]==0) have[j]=1;
if(deg[j]==1&&!have[j]) F(j);
if(deg[j]>=3&&i!=j) ok=0;
}
for(j=0;j<N;j++) if(!have[j]) ok=0;
}
for(auto j:Next[i]) deg[j]++;
ans+=ok;
//if(ok) printf("aa %d\n",i);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |