Submission #287039

# Submission time Handle Problem Language Result Execution time Memory
287039 2020-08-31T09:47:03 Z Atill83 Game (IOI14_game) C++14
100 / 100
789 ms 25336 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
int adj[1501][1501];
int par[1501];
unordered_set<int> comps;
int N;
int find_set(int a){
    if(a == par[a]) return a;
    return par[a] = find_set(par[a]);
}
void merge(int a, int b){
    comps.erase(b);
    par[b] = a;
    adj[a][b] = 1;
    adj[b][a] = 1;
    for(int i = 0; i < N; i++){
        if(i == a) continue;
        if(adj[b][i]){
            adj[a][i] = 1;
            adj[i][a] = 1;
        }
    }
}



void initialize(int n) {
    N = n;
    memset(adj, -1, sizeof(adj));
    for(int i = 0; i < n; i++){ adj[i][i] = 0; par[i] = i; comps.insert(i);}
}

int hasEdge(int u, int v) {
    u = find_set(u);
    v = find_set(v);
    if(u == v) return 0;
    for(int i: comps){
        if(adj[i][u] != 0 && adj[i][v] != 0){
            adj[u][v] = 0;
            adj[v][u] = 0;
             return 0;
        }
    }
    merge(u, v);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9088 KB Output is correct
2 Correct 7 ms 9088 KB Output is correct
3 Correct 6 ms 9088 KB Output is correct
4 Correct 5 ms 9088 KB Output is correct
5 Correct 5 ms 9088 KB Output is correct
6 Correct 6 ms 9088 KB Output is correct
7 Correct 6 ms 9088 KB Output is correct
8 Correct 5 ms 9088 KB Output is correct
9 Correct 5 ms 9088 KB Output is correct
10 Correct 6 ms 9088 KB Output is correct
11 Correct 5 ms 9088 KB Output is correct
12 Correct 7 ms 9088 KB Output is correct
13 Correct 6 ms 9088 KB Output is correct
14 Correct 6 ms 9088 KB Output is correct
15 Correct 5 ms 9088 KB Output is correct
16 Correct 5 ms 9088 KB Output is correct
17 Correct 5 ms 9088 KB Output is correct
18 Correct 5 ms 9088 KB Output is correct
19 Correct 6 ms 9088 KB Output is correct
20 Correct 5 ms 9088 KB Output is correct
21 Correct 5 ms 9088 KB Output is correct
22 Correct 5 ms 9088 KB Output is correct
23 Correct 5 ms 9088 KB Output is correct
24 Correct 6 ms 9088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9088 KB Output is correct
2 Correct 5 ms 9088 KB Output is correct
3 Correct 5 ms 9088 KB Output is correct
4 Correct 6 ms 9088 KB Output is correct
5 Correct 5 ms 9088 KB Output is correct
6 Correct 6 ms 9088 KB Output is correct
7 Correct 6 ms 9088 KB Output is correct
8 Correct 5 ms 9088 KB Output is correct
9 Correct 6 ms 9088 KB Output is correct
10 Correct 6 ms 9088 KB Output is correct
11 Correct 5 ms 9088 KB Output is correct
12 Correct 5 ms 9088 KB Output is correct
13 Correct 5 ms 9088 KB Output is correct
14 Correct 6 ms 9088 KB Output is correct
15 Correct 5 ms 9088 KB Output is correct
16 Correct 5 ms 9088 KB Output is correct
17 Correct 6 ms 9088 KB Output is correct
18 Correct 5 ms 9088 KB Output is correct
19 Correct 6 ms 9088 KB Output is correct
20 Correct 5 ms 9088 KB Output is correct
21 Correct 6 ms 9088 KB Output is correct
22 Correct 6 ms 9088 KB Output is correct
23 Correct 7 ms 9088 KB Output is correct
24 Correct 5 ms 9088 KB Output is correct
25 Correct 6 ms 9088 KB Output is correct
26 Correct 6 ms 9088 KB Output is correct
27 Correct 6 ms 9088 KB Output is correct
28 Correct 6 ms 9088 KB Output is correct
29 Correct 6 ms 9088 KB Output is correct
30 Correct 7 ms 9164 KB Output is correct
31 Correct 6 ms 9088 KB Output is correct
32 Correct 6 ms 9088 KB Output is correct
33 Correct 6 ms 9088 KB Output is correct
34 Correct 7 ms 9216 KB Output is correct
35 Correct 7 ms 9216 KB Output is correct
36 Correct 7 ms 9216 KB Output is correct
37 Correct 7 ms 9216 KB Output is correct
38 Correct 7 ms 9216 KB Output is correct
39 Correct 7 ms 9216 KB Output is correct
40 Correct 7 ms 9216 KB Output is correct
41 Correct 7 ms 9216 KB Output is correct
42 Correct 7 ms 9216 KB Output is correct
43 Correct 7 ms 9216 KB Output is correct
44 Correct 7 ms 9216 KB Output is correct
45 Correct 7 ms 9216 KB Output is correct
46 Correct 7 ms 9216 KB Output is correct
47 Correct 7 ms 9216 KB Output is correct
48 Correct 7 ms 9120 KB Output is correct
49 Correct 7 ms 9216 KB Output is correct
50 Correct 7 ms 9216 KB Output is correct
51 Correct 7 ms 9216 KB Output is correct
52 Correct 7 ms 9216 KB Output is correct
53 Correct 7 ms 9216 KB Output is correct
54 Correct 7 ms 9216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9088 KB Output is correct
2 Correct 5 ms 9088 KB Output is correct
3 Correct 6 ms 9088 KB Output is correct
4 Correct 5 ms 9088 KB Output is correct
5 Correct 6 ms 9088 KB Output is correct
6 Correct 6 ms 9088 KB Output is correct
7 Correct 5 ms 9088 KB Output is correct
8 Correct 5 ms 9088 KB Output is correct
9 Correct 6 ms 9088 KB Output is correct
10 Correct 5 ms 9088 KB Output is correct
11 Correct 6 ms 9088 KB Output is correct
12 Correct 5 ms 9088 KB Output is correct
13 Correct 6 ms 9088 KB Output is correct
14 Correct 5 ms 9088 KB Output is correct
15 Correct 6 ms 9088 KB Output is correct
16 Correct 6 ms 9088 KB Output is correct
17 Correct 5 ms 9088 KB Output is correct
18 Correct 5 ms 9088 KB Output is correct
19 Correct 6 ms 9088 KB Output is correct
20 Correct 6 ms 9088 KB Output is correct
21 Correct 5 ms 9088 KB Output is correct
22 Correct 6 ms 9088 KB Output is correct
23 Correct 5 ms 9088 KB Output is correct
24 Correct 6 ms 9088 KB Output is correct
25 Correct 6 ms 9088 KB Output is correct
26 Correct 7 ms 9088 KB Output is correct
27 Correct 6 ms 9088 KB Output is correct
28 Correct 6 ms 9088 KB Output is correct
29 Correct 6 ms 9088 KB Output is correct
30 Correct 6 ms 9088 KB Output is correct
31 Correct 6 ms 9088 KB Output is correct
32 Correct 6 ms 9088 KB Output is correct
33 Correct 7 ms 9088 KB Output is correct
34 Correct 7 ms 9216 KB Output is correct
35 Correct 7 ms 9216 KB Output is correct
36 Correct 7 ms 9216 KB Output is correct
37 Correct 7 ms 9216 KB Output is correct
38 Correct 7 ms 9216 KB Output is correct
39 Correct 7 ms 9216 KB Output is correct
40 Correct 7 ms 9216 KB Output is correct
41 Correct 8 ms 9216 KB Output is correct
42 Correct 7 ms 9216 KB Output is correct
43 Correct 7 ms 9216 KB Output is correct
44 Correct 7 ms 9216 KB Output is correct
45 Correct 7 ms 9216 KB Output is correct
46 Correct 7 ms 9216 KB Output is correct
47 Correct 7 ms 9216 KB Output is correct
48 Correct 7 ms 9216 KB Output is correct
49 Correct 7 ms 9216 KB Output is correct
50 Correct 7 ms 9216 KB Output is correct
51 Correct 7 ms 9216 KB Output is correct
52 Correct 8 ms 9216 KB Output is correct
53 Correct 7 ms 9216 KB Output is correct
54 Correct 7 ms 9216 KB Output is correct
55 Correct 70 ms 9976 KB Output is correct
56 Correct 66 ms 9976 KB Output is correct
57 Correct 69 ms 9904 KB Output is correct
58 Correct 68 ms 9976 KB Output is correct
59 Correct 68 ms 9976 KB Output is correct
60 Correct 67 ms 9976 KB Output is correct
61 Correct 69 ms 9976 KB Output is correct
62 Correct 68 ms 9976 KB Output is correct
63 Correct 68 ms 9976 KB Output is correct
64 Correct 52 ms 9976 KB Output is correct
65 Correct 108 ms 10104 KB Output is correct
66 Correct 65 ms 9976 KB Output is correct
67 Correct 63 ms 9976 KB Output is correct
68 Correct 61 ms 9976 KB Output is correct
69 Correct 65 ms 9976 KB Output is correct
70 Correct 63 ms 9976 KB Output is correct
71 Correct 80 ms 9976 KB Output is correct
72 Correct 93 ms 9976 KB Output is correct
73 Correct 77 ms 9976 KB Output is correct
74 Correct 75 ms 9976 KB Output is correct
75 Correct 77 ms 9976 KB Output is correct
76 Correct 159 ms 11000 KB Output is correct
77 Correct 163 ms 11000 KB Output is correct
78 Correct 160 ms 11004 KB Output is correct
79 Correct 163 ms 11000 KB Output is correct
80 Correct 157 ms 11000 KB Output is correct
81 Correct 159 ms 11000 KB Output is correct
82 Correct 161 ms 11000 KB Output is correct
83 Correct 168 ms 11000 KB Output is correct
84 Correct 160 ms 11128 KB Output is correct
85 Correct 316 ms 12280 KB Output is correct
86 Correct 313 ms 12284 KB Output is correct
87 Correct 306 ms 12408 KB Output is correct
88 Correct 313 ms 12280 KB Output is correct
89 Correct 309 ms 12280 KB Output is correct
90 Correct 307 ms 12280 KB Output is correct
91 Correct 312 ms 12284 KB Output is correct
92 Correct 307 ms 12280 KB Output is correct
93 Correct 313 ms 12280 KB Output is correct
94 Correct 758 ms 15864 KB Output is correct
95 Correct 779 ms 25208 KB Output is correct
96 Correct 782 ms 25208 KB Output is correct
97 Correct 766 ms 25208 KB Output is correct
98 Correct 776 ms 25336 KB Output is correct
99 Correct 789 ms 25208 KB Output is correct
100 Correct 765 ms 25336 KB Output is correct