Submission #911772

# Submission time Handle Problem Language Result Execution time Memory
911772 2024-01-19T05:11:58 Z Sir_Ahmed_Imran Parachute rings (IOI12_rings) C++17
37 / 100
1460 ms 145052 KB
                              ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long 
#define append push_back
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define MAXN 1000001
int n,x;
int e[MAXN];
int par[MAXN];
int vis[MAXN];
vector<int> a[MAXN];
void dfs(int v,int u,vector<int>& vec){
    vis[v]=1;
    vec.append(v);
    for(auto& i:a[v])
        if(!vis[i])
            dfs(i,u,vec);
    if(vec.back()!=u) vec.pop_back();
}
int root(int v){
    if(par[v]==v) return v;
    par[v]=root(par[v]);
    return par[v];
}
void join(int v,int u){
    par[root(u)]=root(v);
}
bool same(int v,int u){
    return (root(v)==root(u));
}
void Init(int u){
    n=x=u;
    for(int i=0;i<n;i++){
        par[i]=i; 
        e[i]=1;
    }
}
void Link(int v, int u){
    if(!x) return;
    if(a[v].size()==1 && a[u].size()==1 && same(v,u)){
        vector<int> vec;
        for(int i=0;i<n;i++) vis[i]=0;
        dfs(v,u,vec);
        map<int,int> z;
        for(auto& i:vec) z[i]=1;
        for(int i=x=0;i<n;i++){
            if(!z[i]) e[i]=0;
            x+=e[i];
        }
    }
    a[v].append(u);
    a[u].append(v);
    join(v,u);
    if(a[v].size()>3){
        for(int i=0;i<n;i++)
            if(i!=v) e[i]=0;
        x=e[v];
    }
    if(a[u].size()>3){
        for(int i=0;i<n;i++)
            if(i!=u) e[i]=0;
        x=e[u];
    }
    if(a[v].size()==3){
        map<int,int> z;
        z[v]=1;
        for(auto& i:a[v]) z[i]=1;
        for(int i=x=0;i<n;i++){
            if(!z[i]) e[i]=0;
            x+=e[i];
        }
    }
    if(a[u].size()==3){
        map<int,int> z;
        z[u]=1;
        for(auto& i:a[u]) z[i]=1;
        for(int i=x=0;i<n;i++){
            if(!z[i]) e[i]=0;
            x+=e[i];
        }
    }
}
int CountCritical(){
    return x;;
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 29272 KB Output is correct
2 Correct 10 ms 29528 KB Output is correct
3 Correct 10 ms 29532 KB Output is correct
4 Correct 8 ms 29276 KB Output is correct
5 Correct 10 ms 29532 KB Output is correct
6 Correct 12 ms 29788 KB Output is correct
7 Correct 10 ms 29532 KB Output is correct
8 Correct 10 ms 29528 KB Output is correct
9 Correct 10 ms 29532 KB Output is correct
10 Correct 10 ms 29532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 221 ms 49744 KB Output is correct
2 Correct 761 ms 85228 KB Output is correct
3 Correct 500 ms 81232 KB Output is correct
4 Correct 911 ms 113748 KB Output is correct
5 Correct 965 ms 115176 KB Output is correct
6 Correct 1460 ms 145052 KB Output is correct
7 Correct 536 ms 80956 KB Output is correct
8 Correct 1167 ms 104692 KB Output is correct
9 Correct 1246 ms 111920 KB Output is correct
10 Correct 767 ms 112504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 29272 KB Output is correct
2 Correct 10 ms 29528 KB Output is correct
3 Correct 10 ms 29532 KB Output is correct
4 Correct 8 ms 29276 KB Output is correct
5 Correct 10 ms 29532 KB Output is correct
6 Correct 12 ms 29788 KB Output is correct
7 Correct 10 ms 29532 KB Output is correct
8 Correct 10 ms 29528 KB Output is correct
9 Correct 10 ms 29532 KB Output is correct
10 Correct 10 ms 29532 KB Output is correct
11 Incorrect 13 ms 29532 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 29272 KB Output is correct
2 Correct 10 ms 29528 KB Output is correct
3 Correct 10 ms 29532 KB Output is correct
4 Correct 8 ms 29276 KB Output is correct
5 Correct 10 ms 29532 KB Output is correct
6 Correct 12 ms 29788 KB Output is correct
7 Correct 10 ms 29532 KB Output is correct
8 Correct 10 ms 29528 KB Output is correct
9 Correct 10 ms 29532 KB Output is correct
10 Correct 10 ms 29532 KB Output is correct
11 Incorrect 13 ms 29532 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 29272 KB Output is correct
2 Correct 10 ms 29528 KB Output is correct
3 Correct 10 ms 29532 KB Output is correct
4 Correct 8 ms 29276 KB Output is correct
5 Correct 10 ms 29532 KB Output is correct
6 Correct 12 ms 29788 KB Output is correct
7 Correct 10 ms 29532 KB Output is correct
8 Correct 10 ms 29528 KB Output is correct
9 Correct 10 ms 29532 KB Output is correct
10 Correct 10 ms 29532 KB Output is correct
11 Correct 221 ms 49744 KB Output is correct
12 Correct 761 ms 85228 KB Output is correct
13 Correct 500 ms 81232 KB Output is correct
14 Correct 911 ms 113748 KB Output is correct
15 Correct 965 ms 115176 KB Output is correct
16 Correct 1460 ms 145052 KB Output is correct
17 Correct 536 ms 80956 KB Output is correct
18 Correct 1167 ms 104692 KB Output is correct
19 Correct 1246 ms 111920 KB Output is correct
20 Correct 767 ms 112504 KB Output is correct
21 Incorrect 13 ms 29532 KB Output isn't correct
22 Halted 0 ms 0 KB -