답안 #911846

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
911846 2024-01-19T05:48:04 Z Sir_Ahmed_Imran 낙하산 고리들 (IOI12_rings) C++17
55 / 100
4000 ms 165504 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 f[MAXN];
int par[MAXN];
vector<int> a[MAXN];
unordered_map<int,int> e;
unordered_map<int,int> vis;
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){
    v=root(v);
    u=root(u);
    par[u]=v;
    f[v]+=f[u];
}
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(!f[root(v)] && same(v,u)){
        vector<int> vec;
        dfs(v,u,vec);
        vis.clear();
        x=0;
        map<int,int> z;
        for(auto& i:vec) z[i]=e[i];
        e.clear();
        for(auto& i:z){
            if(i.ss){
                x++;
                e[i.ff]=i.ss;
            }
        }
    }
    a[v].append(u);
    a[u].append(v);
    join(v,u);
    if(a[v].size()>3){
        x=e[v];
        e.clear();
        e[v]=x;
    }
    if(a[u].size()>3){
        x=e[u];
        e.clear();
        e[u]=x;
    }
    if(a[v].size()==3){
        map<int,int> z;
        z[v]=e[v];
        for(auto& i:a[v]) z[i]=e[i];
        e.clear();
        x=0;
        for(auto& i:z){
            if(i.ss){
                x++;
                e[i.ff]=i.ss;
            }
        }
    }
    if(a[u].size()==3){
        map<int,int> z;
        z[u]=e[u];
        for(auto& i:a[u]) z[i]=e[i];
        e.clear();
        x=0;
        for(auto& i:z){
            if(i.ss){
                x++;
                e[i.ff]=i.ss;
            }
        }
    }
}
int CountCritical(){
    return x;;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 25176 KB Output is correct
2 Correct 8 ms 25432 KB Output is correct
3 Correct 10 ms 25432 KB Output is correct
4 Correct 8 ms 25176 KB Output is correct
5 Correct 9 ms 25480 KB Output is correct
6 Correct 10 ms 25948 KB Output is correct
7 Correct 8 ms 25436 KB Output is correct
8 Correct 9 ms 25436 KB Output is correct
9 Correct 9 ms 25436 KB Output is correct
10 Correct 10 ms 25616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 304 ms 67392 KB Output is correct
2 Correct 729 ms 80640 KB Output is correct
3 Correct 203 ms 74620 KB Output is correct
4 Correct 951 ms 106064 KB Output is correct
5 Correct 1152 ms 108248 KB Output is correct
6 Correct 1967 ms 165504 KB Output is correct
7 Correct 211 ms 74752 KB Output is correct
8 Correct 855 ms 98300 KB Output is correct
9 Correct 988 ms 104672 KB Output is correct
10 Correct 644 ms 104180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 25176 KB Output is correct
2 Correct 8 ms 25432 KB Output is correct
3 Correct 10 ms 25432 KB Output is correct
4 Correct 8 ms 25176 KB Output is correct
5 Correct 9 ms 25480 KB Output is correct
6 Correct 10 ms 25948 KB Output is correct
7 Correct 8 ms 25436 KB Output is correct
8 Correct 9 ms 25436 KB Output is correct
9 Correct 9 ms 25436 KB Output is correct
10 Correct 10 ms 25616 KB Output is correct
11 Correct 9 ms 25436 KB Output is correct
12 Correct 11 ms 25948 KB Output is correct
13 Correct 12 ms 25924 KB Output is correct
14 Correct 399 ms 25692 KB Output is correct
15 Correct 615 ms 25944 KB Output is correct
16 Correct 11 ms 25948 KB Output is correct
17 Correct 9 ms 25692 KB Output is correct
18 Correct 11 ms 26204 KB Output is correct
19 Correct 12 ms 25948 KB Output is correct
20 Correct 11 ms 25948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 25176 KB Output is correct
2 Correct 8 ms 25432 KB Output is correct
3 Correct 10 ms 25432 KB Output is correct
4 Correct 8 ms 25176 KB Output is correct
5 Correct 9 ms 25480 KB Output is correct
6 Correct 10 ms 25948 KB Output is correct
7 Correct 8 ms 25436 KB Output is correct
8 Correct 9 ms 25436 KB Output is correct
9 Correct 9 ms 25436 KB Output is correct
10 Correct 10 ms 25616 KB Output is correct
11 Correct 9 ms 25436 KB Output is correct
12 Correct 11 ms 25948 KB Output is correct
13 Correct 12 ms 25924 KB Output is correct
14 Correct 399 ms 25692 KB Output is correct
15 Correct 615 ms 25944 KB Output is correct
16 Correct 11 ms 25948 KB Output is correct
17 Correct 9 ms 25692 KB Output is correct
18 Correct 11 ms 26204 KB Output is correct
19 Correct 12 ms 25948 KB Output is correct
20 Correct 11 ms 25948 KB Output is correct
21 Correct 25 ms 28952 KB Output is correct
22 Correct 36 ms 30820 KB Output is correct
23 Correct 42 ms 32972 KB Output is correct
24 Execution timed out 4043 ms 30856 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 25176 KB Output is correct
2 Correct 8 ms 25432 KB Output is correct
3 Correct 10 ms 25432 KB Output is correct
4 Correct 8 ms 25176 KB Output is correct
5 Correct 9 ms 25480 KB Output is correct
6 Correct 10 ms 25948 KB Output is correct
7 Correct 8 ms 25436 KB Output is correct
8 Correct 9 ms 25436 KB Output is correct
9 Correct 9 ms 25436 KB Output is correct
10 Correct 10 ms 25616 KB Output is correct
11 Correct 304 ms 67392 KB Output is correct
12 Correct 729 ms 80640 KB Output is correct
13 Correct 203 ms 74620 KB Output is correct
14 Correct 951 ms 106064 KB Output is correct
15 Correct 1152 ms 108248 KB Output is correct
16 Correct 1967 ms 165504 KB Output is correct
17 Correct 211 ms 74752 KB Output is correct
18 Correct 855 ms 98300 KB Output is correct
19 Correct 988 ms 104672 KB Output is correct
20 Correct 644 ms 104180 KB Output is correct
21 Correct 9 ms 25436 KB Output is correct
22 Correct 11 ms 25948 KB Output is correct
23 Correct 12 ms 25924 KB Output is correct
24 Correct 399 ms 25692 KB Output is correct
25 Correct 615 ms 25944 KB Output is correct
26 Correct 11 ms 25948 KB Output is correct
27 Correct 9 ms 25692 KB Output is correct
28 Correct 11 ms 26204 KB Output is correct
29 Correct 12 ms 25948 KB Output is correct
30 Correct 11 ms 25948 KB Output is correct
31 Correct 25 ms 28952 KB Output is correct
32 Correct 36 ms 30820 KB Output is correct
33 Correct 42 ms 32972 KB Output is correct
34 Execution timed out 4043 ms 30856 KB Time limit exceeded
35 Halted 0 ms 0 KB -