Submission #357283

# Submission time Handle Problem Language Result Execution time Memory
357283 2021-01-24T03:46:02 Z daniel920712 Parachute rings (IOI12_rings) C++14
20 / 100
4000 ms 42768 KB
#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

rings.cpp: In function 'void F(int)':
rings.cpp:25:9: warning: unused variable 't' [-Wunused-variable]
   25 |     int t=0;
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 17 ms 23784 KB Output is correct
2 Correct 650 ms 24048 KB Output is correct
3 Correct 845 ms 24044 KB Output is correct
4 Correct 45 ms 23840 KB Output is correct
5 Correct 258 ms 24028 KB Output is correct
6 Correct 786 ms 24188 KB Output is correct
7 Correct 227 ms 23916 KB Output is correct
8 Correct 194 ms 24052 KB Output is correct
9 Correct 741 ms 24120 KB Output is correct
10 Correct 775 ms 24172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4013 ms 42768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 23784 KB Output is correct
2 Correct 650 ms 24048 KB Output is correct
3 Correct 845 ms 24044 KB Output is correct
4 Correct 45 ms 23840 KB Output is correct
5 Correct 258 ms 24028 KB Output is correct
6 Correct 786 ms 24188 KB Output is correct
7 Correct 227 ms 23916 KB Output is correct
8 Correct 194 ms 24052 KB Output is correct
9 Correct 741 ms 24120 KB Output is correct
10 Correct 775 ms 24172 KB Output is correct
11 Execution timed out 4046 ms 24044 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 23784 KB Output is correct
2 Correct 650 ms 24048 KB Output is correct
3 Correct 845 ms 24044 KB Output is correct
4 Correct 45 ms 23840 KB Output is correct
5 Correct 258 ms 24028 KB Output is correct
6 Correct 786 ms 24188 KB Output is correct
7 Correct 227 ms 23916 KB Output is correct
8 Correct 194 ms 24052 KB Output is correct
9 Correct 741 ms 24120 KB Output is correct
10 Correct 775 ms 24172 KB Output is correct
11 Execution timed out 4046 ms 24044 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 23784 KB Output is correct
2 Correct 650 ms 24048 KB Output is correct
3 Correct 845 ms 24044 KB Output is correct
4 Correct 45 ms 23840 KB Output is correct
5 Correct 258 ms 24028 KB Output is correct
6 Correct 786 ms 24188 KB Output is correct
7 Correct 227 ms 23916 KB Output is correct
8 Correct 194 ms 24052 KB Output is correct
9 Correct 741 ms 24120 KB Output is correct
10 Correct 775 ms 24172 KB Output is correct
11 Execution timed out 4013 ms 42768 KB Time limit exceeded
12 Halted 0 ms 0 KB -