Submission #27150

# Submission time Handle Problem Language Result Execution time Memory
27150 2017-07-09T15:52:36 Z repeating Parachute rings (IOI12_rings) C++11
0 / 100
37 ms 8608 KB
#include <bits/stdc++.h>
//#include "decoder.h"
//#include "decoderlib.h"
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%I64d",&x)
#define SF2(x,y) scanf("%I64d%I64d",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()

using namespace std;
const long long INF = 1e9+5e8;
const int MX=100005;

int n,node=-1;
int par[MX];
int t[MX],cur=1,res;
int up[MX];
int lvl[MX];
vector<int> adj[MX];
bool is_cycil[MX];
void Init(int N_) {
    MEM(up,-1);
    n = N_;
    for(int i=0;i<n;i++){
        par[i]=i;
        t[i]=1;
        lvl[i]=0;
    }
    res=n;
}
int DSU(int x){
    if(x==par[x])R x;
    else{
        int z=DSU(par[x]);
        lvl[x]+=lvl[par[x]];
        par[x]=z;
    }
    R par[x];
}
void check(){
    if(res==1){
        for(int i=0;i<n;i++)
            if(t[i]==cur)
                node=i;
    }
}
void ADD(int A){
    if(adj[A].SI==3){
        res=(t[A]==cur);
        cur++;
        t[A]++;
        for(auto i : adj[A]){
            t[i]++;
            res+=(t[i]==cur);
        }
    }
    if(adj[A].SI>3){
        res=(t[A]==cur);
        cur++;
        t[A]++;
    }
    check();

}
void getup(int A,int B){
    res=0;
    if(lvl[A]<lvl[B])swap(A,B);
    W(lvl[A]>lvl[B]){
        res+=(t[A]==cur);
        t[A]++;
        is_cycil[A]=1;
        A=up[A];
//        cout<<A<<" "<<B<<endl;
    }
    W(A!=B){
        is_cycil[A]=1;
        res+=(t[A]==cur);
        t[A]++;
        A=up[A];
        is_cycil[B]=1;
        res+=(t[B]==cur);
        t[B]++;
        B=up[B];
//        cout<<A<<" "<<B<<endl;
    }
    is_cycil[A]=1;
    res+=(t[A]==cur);
    t[A]++;
    cur++;
}
void check_(int A,int B){
    res=0;
    res+=(t[A]==cur);
    t[A]++;
    res+=(t[B]==cur);
    t[B]++;
    cur++;
}
void Link(int A, int B) {
    if(res==0)R;
    adj[A].pb(B);
    adj[B].pb(A);
    ADD(A);
    ADD(B);
    if(DSU(A)==DSU(B)){
        if(is_cycil[A]&&is_cycil[B]){
            check_(A,B);
        }
        else{
            if(1){
                getup(A,B);
            }
            else{

            }
        }
    }
    else{
        up[A]=B;
    }
    par[DSU(A)]=DSU(B);
    lvl[A]=lvl[B]+1;
}

int CountCritical() {
    return res;
}


# Verdict Execution time Memory Grader output
1 Correct 4 ms 3064 KB Output is correct
2 Correct 14 ms 3452 KB Output is correct
3 Correct 37 ms 3452 KB Output is correct
4 Incorrect 4 ms 3452 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 8608 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3064 KB Output is correct
2 Correct 14 ms 3452 KB Output is correct
3 Correct 37 ms 3452 KB Output is correct
4 Incorrect 4 ms 3452 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3064 KB Output is correct
2 Correct 14 ms 3452 KB Output is correct
3 Correct 37 ms 3452 KB Output is correct
4 Incorrect 4 ms 3452 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3064 KB Output is correct
2 Correct 14 ms 3452 KB Output is correct
3 Correct 37 ms 3452 KB Output is correct
4 Incorrect 4 ms 3452 KB Output isn't correct
5 Halted 0 ms 0 KB -