답안 #592875

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592875 2022-07-09T17:22:14 Z MohamedFaresNebili 낙하산 고리들 (IOI12_rings) C++14
52 / 100
1450 ms 262144 KB
#include <bits/stdc++.h>
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")
 
                using namespace std;
 
                using ll = long long;
                using ld = long double;
                using ii = pair<ll, ll>;
                using vi = vector<int>;
 
                #define ff first
                #define ss second
                #define pb push_back
                #define all(x) (x).begin(), (x).end()
                #define lb lower_bound
 
                int N, P[1000007], C[1000007], S[1000007];
                vector<int> adj[1000007], R;
                set<int> res;
                bool vis[1000007];
 
                int findSet(int v) {
                    if(P[v] == v) return v;
                    return P[v] = findSet(P[v]);
                }
                void unionSet(int u, int v) {
                    u = findSet(u), v = findSet(v);
                    if(u == v) return;
                    P[v] = u; S[u] += S[v];
                }
                void Init(int n) {
                    N = n;
                    for(int l = 0; l < N; l++)
                        P[l] = l, res.insert(l);
                }
                void solve(set<int> cur) {
                    auto it = cur.begin(); set<int> New;
                    while(it != cur.end()) {
                        if(res.count(*it))
                            New.insert(*it);
                        it++;
                    }
                    res.clear(); swap(New, res);
                }
                bool dfs(int v, int p, int d) {
                    C[v] = p; vis[v] = 1;
                    R.push_back(v);
                    if(v == d) {
                        set<int> cur;
                        cur.insert(v); v = C[v];
                        while(v != d) {
                            cur.insert(v); v = C[v];
                        }
                        solve(cur);
                        return 1;
                    }
                    for(auto u : adj[v]) {
                        if(u == p || vis[u]) continue;
                        if(dfs(u, v, d)) return 1;
                    }
                    return 0;
                }
                void Link(int A, int B) {
                    int U = findSet(A), V = findSet(B);
                    adj[A].push_back(B);
                    adj[B].push_back(A);
 
                    if(U == V) {
                        S[U]++;
                        if(S[U] <= 3) dfs(A, B, B);
                        for(auto u : R) vis[u] = 0;
                        R.clear();
 
                        if(S[U] == 2) {
                            set<int> New;
                            auto it = res.begin();
                            while(it != res.end()) {
                                if(adj[*it].size() >= 3)
                                    New.insert(*it);
                                it++;
                            }
                            res.clear(); swap(New, res);
                        }
 
                    }
                    else unionSet(U, V);
 
                    set<int> New;
                    if(adj[A].size() == 4)
                        New.clear(), New.insert(A), solve(New);
                    if(adj[B].size() == 4)
                        New.clear(), New.insert(B), solve(New);
                    if(adj[A].size() == 3) {
                        New.clear(); New.insert(A);
                        for(auto u : adj[A])
                            New.insert(u);
                        solve(New);
                    }
                    if(adj[B].size() == 3) {
                        New.clear(); New.insert(B);
                        for(auto u : adj[B])
                            New.insert(u);
                        solve(New);
                    }
                }
                int CountCritical() {
                    return res.size();
                }
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23772 KB Output is correct
2 Correct 13 ms 24088 KB Output is correct
3 Correct 14 ms 24152 KB Output is correct
4 Correct 12 ms 23892 KB Output is correct
5 Correct 14 ms 24532 KB Output is correct
6 Correct 17 ms 25428 KB Output is correct
7 Correct 13 ms 24032 KB Output is correct
8 Correct 14 ms 24276 KB Output is correct
9 Correct 14 ms 24136 KB Output is correct
10 Correct 15 ms 24148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 424 ms 68604 KB Output is correct
2 Correct 834 ms 81760 KB Output is correct
3 Correct 1184 ms 84048 KB Output is correct
4 Correct 1053 ms 112548 KB Output is correct
5 Correct 1083 ms 121424 KB Output is correct
6 Runtime error 1450 ms 262144 KB Execution killed with signal 9
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23772 KB Output is correct
2 Correct 13 ms 24088 KB Output is correct
3 Correct 14 ms 24152 KB Output is correct
4 Correct 12 ms 23892 KB Output is correct
5 Correct 14 ms 24532 KB Output is correct
6 Correct 17 ms 25428 KB Output is correct
7 Correct 13 ms 24032 KB Output is correct
8 Correct 14 ms 24276 KB Output is correct
9 Correct 14 ms 24136 KB Output is correct
10 Correct 15 ms 24148 KB Output is correct
11 Correct 15 ms 24276 KB Output is correct
12 Correct 21 ms 24916 KB Output is correct
13 Correct 19 ms 24916 KB Output is correct
14 Correct 18 ms 24484 KB Output is correct
15 Correct 19 ms 25004 KB Output is correct
16 Correct 20 ms 24768 KB Output is correct
17 Correct 19 ms 24652 KB Output is correct
18 Correct 22 ms 25076 KB Output is correct
19 Correct 17 ms 24788 KB Output is correct
20 Correct 18 ms 24660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23772 KB Output is correct
2 Correct 13 ms 24088 KB Output is correct
3 Correct 14 ms 24152 KB Output is correct
4 Correct 12 ms 23892 KB Output is correct
5 Correct 14 ms 24532 KB Output is correct
6 Correct 17 ms 25428 KB Output is correct
7 Correct 13 ms 24032 KB Output is correct
8 Correct 14 ms 24276 KB Output is correct
9 Correct 14 ms 24136 KB Output is correct
10 Correct 15 ms 24148 KB Output is correct
11 Correct 15 ms 24276 KB Output is correct
12 Correct 21 ms 24916 KB Output is correct
13 Correct 19 ms 24916 KB Output is correct
14 Correct 18 ms 24484 KB Output is correct
15 Correct 19 ms 25004 KB Output is correct
16 Correct 20 ms 24768 KB Output is correct
17 Correct 19 ms 24652 KB Output is correct
18 Correct 22 ms 25076 KB Output is correct
19 Correct 17 ms 24788 KB Output is correct
20 Correct 18 ms 24660 KB Output is correct
21 Correct 34 ms 27480 KB Output is correct
22 Correct 51 ms 29740 KB Output is correct
23 Correct 61 ms 31300 KB Output is correct
24 Correct 65 ms 29516 KB Output is correct
25 Correct 51 ms 29420 KB Output is correct
26 Correct 61 ms 29776 KB Output is correct
27 Correct 81 ms 31104 KB Output is correct
28 Correct 61 ms 29280 KB Output is correct
29 Correct 59 ms 29648 KB Output is correct
30 Correct 82 ms 36812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23772 KB Output is correct
2 Correct 13 ms 24088 KB Output is correct
3 Correct 14 ms 24152 KB Output is correct
4 Correct 12 ms 23892 KB Output is correct
5 Correct 14 ms 24532 KB Output is correct
6 Correct 17 ms 25428 KB Output is correct
7 Correct 13 ms 24032 KB Output is correct
8 Correct 14 ms 24276 KB Output is correct
9 Correct 14 ms 24136 KB Output is correct
10 Correct 15 ms 24148 KB Output is correct
11 Correct 424 ms 68604 KB Output is correct
12 Correct 834 ms 81760 KB Output is correct
13 Correct 1184 ms 84048 KB Output is correct
14 Correct 1053 ms 112548 KB Output is correct
15 Correct 1083 ms 121424 KB Output is correct
16 Runtime error 1450 ms 262144 KB Execution killed with signal 9
17 Halted 0 ms 0 KB -