Submission #350168

#TimeUsernameProblemLanguageResultExecution timeMemory
350168beksultan04Parachute rings (IOI12_rings)C++14
20 / 100
4051 ms14976 KiB
#include <bits/stdc++.h>
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
const int NN = 3e5+12,INF=1e9+7;
vector <int> g[NN];
int N,M,vis[NN],ans;

void dfs(int x,int p){
    vis[x] = 1;
    bool f=0;
    for (int to: g[x]){
        if (to == p || vis[to] == 2 || ans==0)continue;
        if (vis[to] == 1)ans=0;
        if (vis[to] == 0 && f==1 && p != -1)ans=0;
        if (vis[to] == 0){
            dfs(to,x);
            f=1;
        }
    }
}

void Init(int N_){
    N=N_;
}

void Link(int A, int B) {
    g[A].pb(B);
    g[B].pb(A);
}

int CountCritical() {
    int res = 0,i,j;
    for (i=0;i<N;++i){
        vis[i] = 2;
        ans=1;
        for (j=0;j<N;++j){
            if (vis[j] == 0 && ans){
                dfs(j,-1);
            }
        }
        for (j=0;j<N;++j)vis[j] = 0;
        res+=ans;
    }

    return res;

}






#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...