# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
398786 | 2021-05-04T20:10:26 Z | priority_queue | Connecting Supertrees (IOI20_supertrees) | C++14 | 266 ms | 28036 KB |
// ioi 2020, day 1, supertrees #include <bits/stdc++.h> using namespace std; #define forint(i, N) for (int i = 0; i < (N); i++) using namespace std; void build(vector<vector<int> > b); int construct(vector<vector<int> > p) { int N = p.size(); vector< vector<int> > b(N, vector<int>(N, 0)); vector<bool> visited(N, false); vector<vector<int> > p2(N, vector<int>(N, 0)); forint(i, N) { if (!visited[i]) { // create new. All connected to i also not visited visited[i] = true; vector< vector<int> > circle(1); circle[0].push_back(i); vector<int> path2 = {}; for (int j = i+1; j < N; j++) { if (p[i][j] == 1) { if (visited[j]) { return 0; } b[i][j] = 1; b[j][i] = 1; visited[j] = true; circle[0].push_back(j); continue; } if (p[i][j] == 2) { if (visited[j]) { return 0; } path2.push_back(j); continue; } if (p[i][j] == 3) { return 0; } } if (!path2.empty()) { if (path2.size() < 2) { return 0; } int last = i; forint(j, path2.size()) { if (!visited[path2[j]]) { // make it root b[last][path2[j]] = 1; b[path2[j]][last] = 1; last = path2[j]; visited[path2[j]] = true; circle.push_back({path2[j]}); for (int j2 = j+1; j2 < path2.size(); j2++) { if (!visited[path2[j2]] && p[path2[j]][path2[j2]] == 1) { b[path2[j]][path2[j2]] = 1; b[path2[j2]][path2[j]] = 1; visited[path2[j2]] = true; circle[circle.size()-1].push_back(path2[j2]); } } } } b[i][last] = 1; b[last][i] = 1; } forint(c, circle.size()) { for (int d1 = 0; d1 < circle[c].size(); d1++) { for (int d2 = 0; d2 < circle[c].size(); d2++) { p2[circle[c][d1]][circle[c][d2]] = 1; } } forint(d, circle.size()) { if (c!=d) { for (int d1 = 0; d1 < circle[c].size(); d1++) { for (int d2 = 0; d2 < circle[d].size(); d2++) { p2[circle[c][d1]][circle[d][d2]] = 2; } } } } } } } forint(i, N) { forint(j, N) { if (p2[i][j] != p[i][j]) { return 0; } } } build(b); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 11 ms | 1332 KB | Output is correct |
7 | Correct | 265 ms | 27912 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 11 ms | 1332 KB | Output is correct |
7 | Correct | 265 ms | 27912 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 292 KB | Output is correct |
11 | Correct | 1 ms | 300 KB | Output is correct |
12 | Correct | 11 ms | 1356 KB | Output is correct |
13 | Correct | 243 ms | 27904 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 6 ms | 920 KB | Output is correct |
17 | Correct | 106 ms | 18028 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 208 KB | Output is correct |
20 | Correct | 62 ms | 7144 KB | Output is correct |
21 | Correct | 245 ms | 27908 KB | Output is correct |
22 | Correct | 248 ms | 27844 KB | Output is correct |
23 | Correct | 251 ms | 27900 KB | Output is correct |
24 | Correct | 260 ms | 27844 KB | Output is correct |
25 | Correct | 107 ms | 17988 KB | Output is correct |
26 | Correct | 103 ms | 18028 KB | Output is correct |
27 | Correct | 262 ms | 27928 KB | Output is correct |
28 | Correct | 247 ms | 27972 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 296 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 11 ms | 1364 KB | Output is correct |
9 | Correct | 250 ms | 27844 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 11 ms | 1328 KB | Output is correct |
13 | Correct | 243 ms | 27912 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 5 ms | 972 KB | Output is correct |
17 | Correct | 108 ms | 18044 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 63 ms | 7212 KB | Output is correct |
22 | Correct | 247 ms | 27844 KB | Output is correct |
23 | Correct | 253 ms | 27844 KB | Output is correct |
24 | Correct | 250 ms | 27972 KB | Output is correct |
25 | Correct | 102 ms | 17988 KB | Output is correct |
26 | Correct | 102 ms | 18044 KB | Output is correct |
27 | Correct | 242 ms | 27888 KB | Output is correct |
28 | Correct | 252 ms | 27900 KB | Output is correct |
29 | Correct | 102 ms | 17912 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 292 KB | Output is correct |
4 | Correct | 63 ms | 7148 KB | Output is correct |
5 | Correct | 248 ms | 28036 KB | Output is correct |
6 | Correct | 243 ms | 27844 KB | Output is correct |
7 | Correct | 250 ms | 27844 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 62 ms | 7212 KB | Output is correct |
10 | Correct | 243 ms | 27888 KB | Output is correct |
11 | Correct | 248 ms | 28020 KB | Output is correct |
12 | Correct | 266 ms | 27844 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 63 ms | 7236 KB | Output is correct |
17 | Correct | 245 ms | 27900 KB | Output is correct |
18 | Correct | 243 ms | 27892 KB | Output is correct |
19 | Correct | 256 ms | 28016 KB | Output is correct |
20 | Correct | 244 ms | 27908 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 11 ms | 1332 KB | Output is correct |
7 | Correct | 265 ms | 27912 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 292 KB | Output is correct |
11 | Correct | 1 ms | 300 KB | Output is correct |
12 | Correct | 11 ms | 1356 KB | Output is correct |
13 | Correct | 243 ms | 27904 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 6 ms | 920 KB | Output is correct |
17 | Correct | 106 ms | 18028 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 208 KB | Output is correct |
20 | Correct | 62 ms | 7144 KB | Output is correct |
21 | Correct | 245 ms | 27908 KB | Output is correct |
22 | Correct | 248 ms | 27844 KB | Output is correct |
23 | Correct | 251 ms | 27900 KB | Output is correct |
24 | Correct | 260 ms | 27844 KB | Output is correct |
25 | Correct | 107 ms | 17988 KB | Output is correct |
26 | Correct | 103 ms | 18028 KB | Output is correct |
27 | Correct | 262 ms | 27928 KB | Output is correct |
28 | Correct | 247 ms | 27972 KB | Output is correct |
29 | Correct | 1 ms | 204 KB | Output is correct |
30 | Correct | 1 ms | 204 KB | Output is correct |
31 | Correct | 1 ms | 204 KB | Output is correct |
32 | Correct | 1 ms | 204 KB | Output is correct |
33 | Correct | 1 ms | 296 KB | Output is correct |
34 | Correct | 1 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 204 KB | Output is correct |
36 | Correct | 11 ms | 1364 KB | Output is correct |
37 | Correct | 250 ms | 27844 KB | Output is correct |
38 | Correct | 1 ms | 204 KB | Output is correct |
39 | Correct | 1 ms | 204 KB | Output is correct |
40 | Correct | 11 ms | 1328 KB | Output is correct |
41 | Correct | 243 ms | 27912 KB | Output is correct |
42 | Correct | 1 ms | 204 KB | Output is correct |
43 | Correct | 1 ms | 204 KB | Output is correct |
44 | Correct | 5 ms | 972 KB | Output is correct |
45 | Correct | 108 ms | 18044 KB | Output is correct |
46 | Correct | 1 ms | 204 KB | Output is correct |
47 | Correct | 1 ms | 204 KB | Output is correct |
48 | Correct | 1 ms | 204 KB | Output is correct |
49 | Correct | 63 ms | 7212 KB | Output is correct |
50 | Correct | 247 ms | 27844 KB | Output is correct |
51 | Correct | 253 ms | 27844 KB | Output is correct |
52 | Correct | 250 ms | 27972 KB | Output is correct |
53 | Correct | 102 ms | 17988 KB | Output is correct |
54 | Correct | 102 ms | 18044 KB | Output is correct |
55 | Correct | 242 ms | 27888 KB | Output is correct |
56 | Correct | 252 ms | 27900 KB | Output is correct |
57 | Correct | 102 ms | 17912 KB | Output is correct |
58 | Correct | 1 ms | 204 KB | Output is correct |
59 | Correct | 1 ms | 204 KB | Output is correct |
60 | Correct | 5 ms | 972 KB | Output is correct |
61 | Correct | 109 ms | 18044 KB | Output is correct |
62 | Correct | 1 ms | 204 KB | Output is correct |
63 | Correct | 1 ms | 208 KB | Output is correct |
64 | Correct | 1 ms | 204 KB | Output is correct |
65 | Correct | 63 ms | 7216 KB | Output is correct |
66 | Correct | 107 ms | 18044 KB | Output is correct |
67 | Correct | 108 ms | 17956 KB | Output is correct |
68 | Correct | 102 ms | 18032 KB | Output is correct |
69 | Correct | 100 ms | 18036 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 11 ms | 1332 KB | Output is correct |
7 | Correct | 265 ms | 27912 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 292 KB | Output is correct |
11 | Correct | 1 ms | 300 KB | Output is correct |
12 | Correct | 11 ms | 1356 KB | Output is correct |
13 | Correct | 243 ms | 27904 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 6 ms | 920 KB | Output is correct |
17 | Correct | 106 ms | 18028 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 208 KB | Output is correct |
20 | Correct | 62 ms | 7144 KB | Output is correct |
21 | Correct | 245 ms | 27908 KB | Output is correct |
22 | Correct | 248 ms | 27844 KB | Output is correct |
23 | Correct | 251 ms | 27900 KB | Output is correct |
24 | Correct | 260 ms | 27844 KB | Output is correct |
25 | Correct | 107 ms | 17988 KB | Output is correct |
26 | Correct | 103 ms | 18028 KB | Output is correct |
27 | Correct | 262 ms | 27928 KB | Output is correct |
28 | Correct | 247 ms | 27972 KB | Output is correct |
29 | Correct | 1 ms | 204 KB | Output is correct |
30 | Correct | 1 ms | 204 KB | Output is correct |
31 | Correct | 1 ms | 204 KB | Output is correct |
32 | Correct | 1 ms | 204 KB | Output is correct |
33 | Correct | 1 ms | 296 KB | Output is correct |
34 | Correct | 1 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 204 KB | Output is correct |
36 | Correct | 11 ms | 1364 KB | Output is correct |
37 | Correct | 250 ms | 27844 KB | Output is correct |
38 | Correct | 1 ms | 204 KB | Output is correct |
39 | Correct | 1 ms | 204 KB | Output is correct |
40 | Correct | 11 ms | 1328 KB | Output is correct |
41 | Correct | 243 ms | 27912 KB | Output is correct |
42 | Correct | 1 ms | 204 KB | Output is correct |
43 | Correct | 1 ms | 204 KB | Output is correct |
44 | Correct | 5 ms | 972 KB | Output is correct |
45 | Correct | 108 ms | 18044 KB | Output is correct |
46 | Correct | 1 ms | 204 KB | Output is correct |
47 | Correct | 1 ms | 204 KB | Output is correct |
48 | Correct | 1 ms | 204 KB | Output is correct |
49 | Correct | 63 ms | 7212 KB | Output is correct |
50 | Correct | 247 ms | 27844 KB | Output is correct |
51 | Correct | 253 ms | 27844 KB | Output is correct |
52 | Correct | 250 ms | 27972 KB | Output is correct |
53 | Correct | 102 ms | 17988 KB | Output is correct |
54 | Correct | 102 ms | 18044 KB | Output is correct |
55 | Correct | 242 ms | 27888 KB | Output is correct |
56 | Correct | 252 ms | 27900 KB | Output is correct |
57 | Correct | 102 ms | 17912 KB | Output is correct |
58 | Correct | 1 ms | 204 KB | Output is correct |
59 | Correct | 1 ms | 204 KB | Output is correct |
60 | Correct | 1 ms | 292 KB | Output is correct |
61 | Correct | 63 ms | 7148 KB | Output is correct |
62 | Correct | 248 ms | 28036 KB | Output is correct |
63 | Correct | 243 ms | 27844 KB | Output is correct |
64 | Correct | 250 ms | 27844 KB | Output is correct |
65 | Correct | 1 ms | 204 KB | Output is correct |
66 | Correct | 62 ms | 7212 KB | Output is correct |
67 | Correct | 243 ms | 27888 KB | Output is correct |
68 | Correct | 248 ms | 28020 KB | Output is correct |
69 | Correct | 266 ms | 27844 KB | Output is correct |
70 | Correct | 1 ms | 204 KB | Output is correct |
71 | Correct | 1 ms | 204 KB | Output is correct |
72 | Correct | 1 ms | 204 KB | Output is correct |
73 | Correct | 63 ms | 7236 KB | Output is correct |
74 | Correct | 245 ms | 27900 KB | Output is correct |
75 | Correct | 243 ms | 27892 KB | Output is correct |
76 | Correct | 256 ms | 28016 KB | Output is correct |
77 | Correct | 244 ms | 27908 KB | Output is correct |
78 | Correct | 1 ms | 204 KB | Output is correct |
79 | Correct | 1 ms | 204 KB | Output is correct |
80 | Correct | 5 ms | 972 KB | Output is correct |
81 | Correct | 109 ms | 18044 KB | Output is correct |
82 | Correct | 1 ms | 204 KB | Output is correct |
83 | Correct | 1 ms | 208 KB | Output is correct |
84 | Correct | 1 ms | 204 KB | Output is correct |
85 | Correct | 63 ms | 7216 KB | Output is correct |
86 | Correct | 107 ms | 18044 KB | Output is correct |
87 | Correct | 108 ms | 17956 KB | Output is correct |
88 | Correct | 102 ms | 18032 KB | Output is correct |
89 | Correct | 100 ms | 18036 KB | Output is correct |
90 | Correct | 1 ms | 204 KB | Output is correct |
91 | Correct | 1 ms | 292 KB | Output is correct |
92 | Correct | 5 ms | 976 KB | Output is correct |
93 | Correct | 99 ms | 18044 KB | Output is correct |
94 | Correct | 1 ms | 204 KB | Output is correct |
95 | Correct | 1 ms | 204 KB | Output is correct |
96 | Correct | 1 ms | 204 KB | Output is correct |
97 | Correct | 26 ms | 4724 KB | Output is correct |
98 | Correct | 102 ms | 18040 KB | Output is correct |
99 | Correct | 103 ms | 18028 KB | Output is correct |
100 | Correct | 104 ms | 17988 KB | Output is correct |
101 | Correct | 102 ms | 18028 KB | Output is correct |
102 | Correct | 94 ms | 17916 KB | Output is correct |
103 | Correct | 97 ms | 17992 KB | Output is correct |
104 | Correct | 90 ms | 17988 KB | Output is correct |
105 | Correct | 107 ms | 18028 KB | Output is correct |