Submission #1009058

# Submission time Handle Problem Language Result Execution time Memory
1009058 2024-06-27T08:26:15 Z erering Parachute rings (IOI12_rings) C++17
0 / 100
4000 ms 41044 KB
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define ll long long
const long long inf=1e18;
const int MOD=998244353;
const int N=1e6+5;
vector<int> adj[N];
int n;
bool vis[N];
struct info{
    int one;
    int two;
    int three;
    int mx;
};
info dfs(int node,int par,int kr){
    vis[node]=1;
    info rt; rt.one=0; rt.two=0; rt.three=0; rt.mx=0;
    int bad=0;
    for(auto i:adj[node]){
        if(i!=kr)bad++;
        if(vis[i])continue;
        info s=dfs(i,node,kr);
        rt.one+=s.one;
        rt.two+=s.two;
        rt.three+=s.three;
        rt.mx=max(rt.mx,s.mx);
    }
    if(bad<=1)rt.one+=1;
    if(bad==2)rt.two=+1;
    if(bad==3)rt.three+=1;
    rt.mx=max(rt.mx,bad);
    return rt;
}
void Init(int N){
    n=N;
}
void Link(int A, int B){
    adj[A].pb(B);
    adj[B].pb(A);
}
int CountCritical(){
    for(int i=1;i<=n;i++)vis[i]=0;
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)vis[j]=0;
        vis[i]=1;
        bool flag=1;
        for(int j=1;j<=n;j++){
            if(!vis[j]){
                info yes=dfs(j,0,i);
                if(yes.mx==0)continue;
                if(yes.mx>=3 || yes.one!=2)flag=0;
            }
        }
        if(flag){
            ans++;
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 24664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4046 ms 41044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 24664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 24664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 24664 KB Output isn't correct
2 Halted 0 ms 0 KB -