답안 #911852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
911852 2024-01-19T05:51:10 Z Sir_Ahmed_Imran 낙하산 고리들 (IOI12_rings) C++17
55 / 100
4000 ms 165580 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;
            }
        }
        f[root(v)]==1;
    }
    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;;
}

Compilation message

rings.cpp: In function 'void Link(int, int)':
rings.cpp:63:19: warning: value computed is not used [-Wunused-value]
   63 |         f[root(v)]==1;
      |         ~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 25176 KB Output is correct
2 Correct 8 ms 25432 KB Output is correct
3 Correct 9 ms 25436 KB Output is correct
4 Correct 7 ms 25176 KB Output is correct
5 Correct 11 ms 25692 KB Output is correct
6 Correct 11 ms 25944 KB Output is correct
7 Correct 8 ms 25436 KB Output is correct
8 Correct 9 ms 25588 KB Output is correct
9 Correct 9 ms 25436 KB Output is correct
10 Correct 9 ms 25456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 343 ms 67500 KB Output is correct
2 Correct 839 ms 80488 KB Output is correct
3 Correct 223 ms 74784 KB Output is correct
4 Correct 984 ms 105672 KB Output is correct
5 Correct 958 ms 108064 KB Output is correct
6 Correct 1966 ms 165580 KB Output is correct
7 Correct 203 ms 74752 KB Output is correct
8 Correct 956 ms 98508 KB Output is correct
9 Correct 1041 ms 104708 KB Output is correct
10 Correct 678 ms 104184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 25176 KB Output is correct
2 Correct 8 ms 25432 KB Output is correct
3 Correct 9 ms 25436 KB Output is correct
4 Correct 7 ms 25176 KB Output is correct
5 Correct 11 ms 25692 KB Output is correct
6 Correct 11 ms 25944 KB Output is correct
7 Correct 8 ms 25436 KB Output is correct
8 Correct 9 ms 25588 KB Output is correct
9 Correct 9 ms 25436 KB Output is correct
10 Correct 9 ms 25456 KB Output is correct
11 Correct 10 ms 25432 KB Output is correct
12 Correct 10 ms 25948 KB Output is correct
13 Correct 11 ms 25692 KB Output is correct
14 Correct 466 ms 25716 KB Output is correct
15 Correct 615 ms 26160 KB Output is correct
16 Correct 10 ms 25948 KB Output is correct
17 Correct 9 ms 25688 KB Output is correct
18 Correct 10 ms 26204 KB Output is correct
19 Correct 10 ms 25948 KB Output is correct
20 Correct 10 ms 25948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 25176 KB Output is correct
2 Correct 8 ms 25432 KB Output is correct
3 Correct 9 ms 25436 KB Output is correct
4 Correct 7 ms 25176 KB Output is correct
5 Correct 11 ms 25692 KB Output is correct
6 Correct 11 ms 25944 KB Output is correct
7 Correct 8 ms 25436 KB Output is correct
8 Correct 9 ms 25588 KB Output is correct
9 Correct 9 ms 25436 KB Output is correct
10 Correct 9 ms 25456 KB Output is correct
11 Correct 10 ms 25432 KB Output is correct
12 Correct 10 ms 25948 KB Output is correct
13 Correct 11 ms 25692 KB Output is correct
14 Correct 466 ms 25716 KB Output is correct
15 Correct 615 ms 26160 KB Output is correct
16 Correct 10 ms 25948 KB Output is correct
17 Correct 9 ms 25688 KB Output is correct
18 Correct 10 ms 26204 KB Output is correct
19 Correct 10 ms 25948 KB Output is correct
20 Correct 10 ms 25948 KB Output is correct
21 Correct 24 ms 28520 KB Output is correct
22 Correct 42 ms 30304 KB Output is correct
23 Correct 41 ms 32136 KB Output is correct
24 Execution timed out 4048 ms 30208 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 25176 KB Output is correct
2 Correct 8 ms 25432 KB Output is correct
3 Correct 9 ms 25436 KB Output is correct
4 Correct 7 ms 25176 KB Output is correct
5 Correct 11 ms 25692 KB Output is correct
6 Correct 11 ms 25944 KB Output is correct
7 Correct 8 ms 25436 KB Output is correct
8 Correct 9 ms 25588 KB Output is correct
9 Correct 9 ms 25436 KB Output is correct
10 Correct 9 ms 25456 KB Output is correct
11 Correct 343 ms 67500 KB Output is correct
12 Correct 839 ms 80488 KB Output is correct
13 Correct 223 ms 74784 KB Output is correct
14 Correct 984 ms 105672 KB Output is correct
15 Correct 958 ms 108064 KB Output is correct
16 Correct 1966 ms 165580 KB Output is correct
17 Correct 203 ms 74752 KB Output is correct
18 Correct 956 ms 98508 KB Output is correct
19 Correct 1041 ms 104708 KB Output is correct
20 Correct 678 ms 104184 KB Output is correct
21 Correct 10 ms 25432 KB Output is correct
22 Correct 10 ms 25948 KB Output is correct
23 Correct 11 ms 25692 KB Output is correct
24 Correct 466 ms 25716 KB Output is correct
25 Correct 615 ms 26160 KB Output is correct
26 Correct 10 ms 25948 KB Output is correct
27 Correct 9 ms 25688 KB Output is correct
28 Correct 10 ms 26204 KB Output is correct
29 Correct 10 ms 25948 KB Output is correct
30 Correct 10 ms 25948 KB Output is correct
31 Correct 24 ms 28520 KB Output is correct
32 Correct 42 ms 30304 KB Output is correct
33 Correct 41 ms 32136 KB Output is correct
34 Execution timed out 4048 ms 30208 KB Time limit exceeded
35 Halted 0 ms 0 KB -