Submission #350942

# Submission time Handle Problem Language Result Execution time Memory
350942 2021-01-19T10:05:39 Z juggernaut Parachute rings (IOI12_rings) C++14
20 / 100
4000 ms 42732 KB
#ifndef EVAL
#include"grader.cpp"
#endif
#include<bits/stdc++.h>
using namespace std;
vector<int>g[1000005];
bool on[1000005],vis[1000005];
int n,deg[1000005];
int counter[5];
bool flag;
int cycle_size,cycle_number;
void update_counter(int x,int y){
    counter[min(x,4)]+=y;
}
#define DEBUG(x) cout<<#x<<"="<<x<<"\n"
void go(int v,int p){
    if(on[v])return;
    cycle_size++;
    vis[v]=1;
    for(int to:g[v])if(to!=p){
        if(vis[to]){
            flag=true;
            continue;
        }
        go(to,v);
    }
}
bool check(){
    for(int i=0;i<n;i++)vis[i]=0;
    for(int i=0;i<n;i++){
        if(on[i])continue;
        if(deg[i]>2)return false;
        if(vis[i])continue;
        flag=false;
        go(i,i);
        if(flag)return false;
    }
    return true;
}
void Init(int N){
    n=N;
    counter[0]=n;
}
void Link(int x,int y){
    g[x].push_back(y);
    g[y].push_back(x);
    update_counter(deg[x],-1);
    update_counter(deg[y],-1);
    deg[x]++;
    deg[y]++;
    update_counter(deg[x],+1);
    update_counter(deg[y],+1);
}
int CountCritical(){
    if(counter[4]){
        if(counter[4]!=1)return 0;
        for(int i=0;i<n;i++)
            if(deg[i]>3){
                on[i]=true;
                for(int to:g[i])deg[i]--,deg[to]--;
                int ans=check();
                for(int to:g[i])deg[i]++,deg[to]++;
                on[i]=false;
                return ans;
            }
    }else{
        int cnt=0;
        for(int i=0;i<n;i++){
            on[i]=true;
            for(int to:g[i])deg[i]--,deg[to]--;
            cnt+=check();
            for(int to:g[i])deg[i]++,deg[to]++;
            on[i]=false;
        }
        return cnt;
    }
}
/*
7 13
-1
1 2
-1
0 5
-1
2 0
-1
3 2
-1
3 5
-1
4 3
-1

*/

Compilation message

rings.cpp: In function 'int CountCritical()':
rings.cpp:77:1: warning: control reaches end of non-void function [-Wreturn-type]
   77 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 16 ms 23788 KB Output is correct
2 Correct 19 ms 24048 KB Output is correct
3 Correct 17 ms 24064 KB Output is correct
4 Correct 27 ms 23916 KB Output is correct
5 Correct 201 ms 24044 KB Output is correct
6 Correct 671 ms 24268 KB Output is correct
7 Correct 71 ms 23916 KB Output is correct
8 Correct 77 ms 24044 KB Output is correct
9 Correct 561 ms 24044 KB Output is correct
10 Correct 576 ms 24120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4042 ms 42732 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 23788 KB Output is correct
2 Correct 19 ms 24048 KB Output is correct
3 Correct 17 ms 24064 KB Output is correct
4 Correct 27 ms 23916 KB Output is correct
5 Correct 201 ms 24044 KB Output is correct
6 Correct 671 ms 24268 KB Output is correct
7 Correct 71 ms 23916 KB Output is correct
8 Correct 77 ms 24044 KB Output is correct
9 Correct 561 ms 24044 KB Output is correct
10 Correct 576 ms 24120 KB Output is correct
11 Execution timed out 4037 ms 24128 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 23788 KB Output is correct
2 Correct 19 ms 24048 KB Output is correct
3 Correct 17 ms 24064 KB Output is correct
4 Correct 27 ms 23916 KB Output is correct
5 Correct 201 ms 24044 KB Output is correct
6 Correct 671 ms 24268 KB Output is correct
7 Correct 71 ms 23916 KB Output is correct
8 Correct 77 ms 24044 KB Output is correct
9 Correct 561 ms 24044 KB Output is correct
10 Correct 576 ms 24120 KB Output is correct
11 Execution timed out 4037 ms 24128 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 23788 KB Output is correct
2 Correct 19 ms 24048 KB Output is correct
3 Correct 17 ms 24064 KB Output is correct
4 Correct 27 ms 23916 KB Output is correct
5 Correct 201 ms 24044 KB Output is correct
6 Correct 671 ms 24268 KB Output is correct
7 Correct 71 ms 23916 KB Output is correct
8 Correct 77 ms 24044 KB Output is correct
9 Correct 561 ms 24044 KB Output is correct
10 Correct 576 ms 24120 KB Output is correct
11 Execution timed out 4042 ms 42732 KB Time limit exceeded
12 Halted 0 ms 0 KB -