# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
301525 | 2020-09-18T03:44:06 Z | kevinsogo | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 282 ms | 26360 KB |
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; vector<int> get_comp(const vector<vector<int>>& adj, vector<bool>& vis, int s) { assert(!vis[s]); vis[s] = true; vector<int> que(1, s); for (int f = 0; f < que.size(); f++) { int i = que[f]; assert(vis[i]); for (int j : adj[i]) { if (!vis[j]) { vis[j] = true; que.push_back(j); } } } return que; } int construct(vector<vector<int>> p) { int n = p.size(); vector<vector<int>> ans(n, vector<int>(n)); vector<vector<int>> adjtree(n), adjcycl(n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (p[i][j] == 3) return 0; if (p[i][j] == 1) adjtree[i].push_back(j); } } vector<vector<int>> trees; vector<int> roots; vector<bool> vis(n); for (int s = 0; s < n; s++) { if (!vis[s]) { trees.push_back(get_comp(adjtree, vis, s)); roots.push_back(trees.back().back()); } } for (int t1 = 0; t1 < trees.size(); t1++) { for (int t2 = 0; t2 < trees.size(); t2++) { int target = p[roots[t1]][roots[t2]]; if (target == 0 && t1 == t2) return 0; if (target == 1 && t1 != t2) return 0; if (target == 2 && t1 == t2) return 0; for (int i1 : trees[t1]) for (int i2 : trees[t2]) { if (p[i1][i2] != target) return 0; } } } // build trees for (auto& tree : trees) { for (int i = 1; i < tree.size(); i++) { ans[tree[0]][tree[i]] = 1; } } // build cycles for (int i : roots) for (int j : roots) { if (p[i][j] == 2) adjcycl[i].push_back(j); } vis = vector<bool>(n); for (int s : roots) { if (!vis[s]) { vector<int> cycle = get_comp(adjcycl, vis, s); for (int i : cycle) for (int j : cycle) { if (i != j && p[i][j] != 2) return 0; } if (cycle.size() > 1) { for (int i = 0, j = cycle.size() - 1; i < cycle.size(); j = i++) { ans[cycle[i]][cycle[j]] = 1; } } if (cycle.size() == 2) return 0; } } // fix grid for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { ans[i][j] |= ans[j][i]; ans[j][i] |= ans[i][j]; } } for (int i = 0; i < n; i++) { ans[i][i] = 0; } build(ans); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 11 ms | 1408 KB | Output is correct |
7 | Correct | 264 ms | 26104 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 11 ms | 1408 KB | Output is correct |
7 | Correct | 264 ms | 26104 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 11 ms | 1280 KB | Output is correct |
13 | Correct | 276 ms | 22264 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 5 ms | 896 KB | Output is correct |
17 | Correct | 134 ms | 14616 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 69 ms | 5880 KB | Output is correct |
21 | Correct | 263 ms | 22616 KB | Output is correct |
22 | Correct | 257 ms | 22228 KB | Output is correct |
23 | Correct | 260 ms | 24184 KB | Output is correct |
24 | Correct | 260 ms | 22264 KB | Output is correct |
25 | Correct | 106 ms | 12664 KB | Output is correct |
26 | Correct | 108 ms | 12280 KB | Output is correct |
27 | Correct | 266 ms | 25336 KB | Output is correct |
28 | Correct | 250 ms | 22268 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 1 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 11 ms | 1280 KB | Output is correct |
9 | Correct | 260 ms | 22264 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 12 ms | 1408 KB | Output is correct |
13 | Correct | 272 ms | 26360 KB | Output is correct |
14 | Correct | 1 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 6 ms | 896 KB | Output is correct |
17 | Correct | 135 ms | 14840 KB | Output is correct |
18 | Correct | 1 ms | 256 KB | Output is correct |
19 | Correct | 1 ms | 256 KB | Output is correct |
20 | Correct | 1 ms | 256 KB | Output is correct |
21 | Correct | 64 ms | 5880 KB | Output is correct |
22 | Correct | 258 ms | 22776 KB | Output is correct |
23 | Correct | 250 ms | 22264 KB | Output is correct |
24 | Correct | 270 ms | 25336 KB | Output is correct |
25 | Correct | 109 ms | 12280 KB | Output is correct |
26 | Correct | 121 ms | 12792 KB | Output is correct |
27 | Correct | 260 ms | 22264 KB | Output is correct |
28 | Correct | 282 ms | 24188 KB | Output is correct |
29 | Correct | 107 ms | 12244 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 66 ms | 5880 KB | Output is correct |
5 | Correct | 251 ms | 22652 KB | Output is correct |
6 | Correct | 254 ms | 22264 KB | Output is correct |
7 | Correct | 268 ms | 24184 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 69 ms | 5880 KB | Output is correct |
10 | Correct | 259 ms | 22776 KB | Output is correct |
11 | Correct | 252 ms | 22520 KB | Output is correct |
12 | Correct | 273 ms | 25336 KB | Output is correct |
13 | Correct | 1 ms | 256 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 65 ms | 5880 KB | Output is correct |
17 | Correct | 254 ms | 22776 KB | Output is correct |
18 | Correct | 260 ms | 22624 KB | Output is correct |
19 | Correct | 250 ms | 22392 KB | Output is correct |
20 | Correct | 253 ms | 22392 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 11 ms | 1408 KB | Output is correct |
7 | Correct | 264 ms | 26104 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 11 ms | 1280 KB | Output is correct |
13 | Correct | 276 ms | 22264 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 5 ms | 896 KB | Output is correct |
17 | Correct | 134 ms | 14616 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 69 ms | 5880 KB | Output is correct |
21 | Correct | 263 ms | 22616 KB | Output is correct |
22 | Correct | 257 ms | 22228 KB | Output is correct |
23 | Correct | 260 ms | 24184 KB | Output is correct |
24 | Correct | 260 ms | 22264 KB | Output is correct |
25 | Correct | 106 ms | 12664 KB | Output is correct |
26 | Correct | 108 ms | 12280 KB | Output is correct |
27 | Correct | 266 ms | 25336 KB | Output is correct |
28 | Correct | 250 ms | 22268 KB | Output is correct |
29 | Correct | 0 ms | 256 KB | Output is correct |
30 | Correct | 0 ms | 256 KB | Output is correct |
31 | Correct | 0 ms | 256 KB | Output is correct |
32 | Correct | 1 ms | 256 KB | Output is correct |
33 | Correct | 1 ms | 256 KB | Output is correct |
34 | Correct | 1 ms | 256 KB | Output is correct |
35 | Correct | 1 ms | 256 KB | Output is correct |
36 | Correct | 11 ms | 1280 KB | Output is correct |
37 | Correct | 260 ms | 22264 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 1 ms | 256 KB | Output is correct |
40 | Correct | 12 ms | 1408 KB | Output is correct |
41 | Correct | 272 ms | 26360 KB | Output is correct |
42 | Correct | 1 ms | 256 KB | Output is correct |
43 | Correct | 1 ms | 256 KB | Output is correct |
44 | Correct | 6 ms | 896 KB | Output is correct |
45 | Correct | 135 ms | 14840 KB | Output is correct |
46 | Correct | 1 ms | 256 KB | Output is correct |
47 | Correct | 1 ms | 256 KB | Output is correct |
48 | Correct | 1 ms | 256 KB | Output is correct |
49 | Correct | 64 ms | 5880 KB | Output is correct |
50 | Correct | 258 ms | 22776 KB | Output is correct |
51 | Correct | 250 ms | 22264 KB | Output is correct |
52 | Correct | 270 ms | 25336 KB | Output is correct |
53 | Correct | 109 ms | 12280 KB | Output is correct |
54 | Correct | 121 ms | 12792 KB | Output is correct |
55 | Correct | 260 ms | 22264 KB | Output is correct |
56 | Correct | 282 ms | 24188 KB | Output is correct |
57 | Correct | 107 ms | 12244 KB | Output is correct |
58 | Correct | 1 ms | 256 KB | Output is correct |
59 | Correct | 1 ms | 256 KB | Output is correct |
60 | Correct | 5 ms | 896 KB | Output is correct |
61 | Correct | 120 ms | 14456 KB | Output is correct |
62 | Correct | 1 ms | 256 KB | Output is correct |
63 | Correct | 1 ms | 384 KB | Output is correct |
64 | Correct | 1 ms | 256 KB | Output is correct |
65 | Correct | 63 ms | 5880 KB | Output is correct |
66 | Correct | 109 ms | 12284 KB | Output is correct |
67 | Correct | 104 ms | 12280 KB | Output is correct |
68 | Correct | 103 ms | 12504 KB | Output is correct |
69 | Correct | 110 ms | 12284 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 11 ms | 1408 KB | Output is correct |
7 | Correct | 264 ms | 26104 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 11 ms | 1280 KB | Output is correct |
13 | Correct | 276 ms | 22264 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 5 ms | 896 KB | Output is correct |
17 | Correct | 134 ms | 14616 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 69 ms | 5880 KB | Output is correct |
21 | Correct | 263 ms | 22616 KB | Output is correct |
22 | Correct | 257 ms | 22228 KB | Output is correct |
23 | Correct | 260 ms | 24184 KB | Output is correct |
24 | Correct | 260 ms | 22264 KB | Output is correct |
25 | Correct | 106 ms | 12664 KB | Output is correct |
26 | Correct | 108 ms | 12280 KB | Output is correct |
27 | Correct | 266 ms | 25336 KB | Output is correct |
28 | Correct | 250 ms | 22268 KB | Output is correct |
29 | Correct | 0 ms | 256 KB | Output is correct |
30 | Correct | 0 ms | 256 KB | Output is correct |
31 | Correct | 0 ms | 256 KB | Output is correct |
32 | Correct | 1 ms | 256 KB | Output is correct |
33 | Correct | 1 ms | 256 KB | Output is correct |
34 | Correct | 1 ms | 256 KB | Output is correct |
35 | Correct | 1 ms | 256 KB | Output is correct |
36 | Correct | 11 ms | 1280 KB | Output is correct |
37 | Correct | 260 ms | 22264 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 1 ms | 256 KB | Output is correct |
40 | Correct | 12 ms | 1408 KB | Output is correct |
41 | Correct | 272 ms | 26360 KB | Output is correct |
42 | Correct | 1 ms | 256 KB | Output is correct |
43 | Correct | 1 ms | 256 KB | Output is correct |
44 | Correct | 6 ms | 896 KB | Output is correct |
45 | Correct | 135 ms | 14840 KB | Output is correct |
46 | Correct | 1 ms | 256 KB | Output is correct |
47 | Correct | 1 ms | 256 KB | Output is correct |
48 | Correct | 1 ms | 256 KB | Output is correct |
49 | Correct | 64 ms | 5880 KB | Output is correct |
50 | Correct | 258 ms | 22776 KB | Output is correct |
51 | Correct | 250 ms | 22264 KB | Output is correct |
52 | Correct | 270 ms | 25336 KB | Output is correct |
53 | Correct | 109 ms | 12280 KB | Output is correct |
54 | Correct | 121 ms | 12792 KB | Output is correct |
55 | Correct | 260 ms | 22264 KB | Output is correct |
56 | Correct | 282 ms | 24188 KB | Output is correct |
57 | Correct | 107 ms | 12244 KB | Output is correct |
58 | Correct | 1 ms | 256 KB | Output is correct |
59 | Correct | 1 ms | 256 KB | Output is correct |
60 | Correct | 1 ms | 256 KB | Output is correct |
61 | Correct | 66 ms | 5880 KB | Output is correct |
62 | Correct | 251 ms | 22652 KB | Output is correct |
63 | Correct | 254 ms | 22264 KB | Output is correct |
64 | Correct | 268 ms | 24184 KB | Output is correct |
65 | Correct | 1 ms | 256 KB | Output is correct |
66 | Correct | 69 ms | 5880 KB | Output is correct |
67 | Correct | 259 ms | 22776 KB | Output is correct |
68 | Correct | 252 ms | 22520 KB | Output is correct |
69 | Correct | 273 ms | 25336 KB | Output is correct |
70 | Correct | 1 ms | 256 KB | Output is correct |
71 | Correct | 1 ms | 384 KB | Output is correct |
72 | Correct | 1 ms | 256 KB | Output is correct |
73 | Correct | 65 ms | 5880 KB | Output is correct |
74 | Correct | 254 ms | 22776 KB | Output is correct |
75 | Correct | 260 ms | 22624 KB | Output is correct |
76 | Correct | 250 ms | 22392 KB | Output is correct |
77 | Correct | 253 ms | 22392 KB | Output is correct |
78 | Correct | 1 ms | 256 KB | Output is correct |
79 | Correct | 1 ms | 256 KB | Output is correct |
80 | Correct | 5 ms | 896 KB | Output is correct |
81 | Correct | 120 ms | 14456 KB | Output is correct |
82 | Correct | 1 ms | 256 KB | Output is correct |
83 | Correct | 1 ms | 384 KB | Output is correct |
84 | Correct | 1 ms | 256 KB | Output is correct |
85 | Correct | 63 ms | 5880 KB | Output is correct |
86 | Correct | 109 ms | 12284 KB | Output is correct |
87 | Correct | 104 ms | 12280 KB | Output is correct |
88 | Correct | 103 ms | 12504 KB | Output is correct |
89 | Correct | 110 ms | 12284 KB | Output is correct |
90 | Correct | 1 ms | 256 KB | Output is correct |
91 | Correct | 1 ms | 256 KB | Output is correct |
92 | Correct | 5 ms | 768 KB | Output is correct |
93 | Correct | 109 ms | 12152 KB | Output is correct |
94 | Correct | 1 ms | 384 KB | Output is correct |
95 | Correct | 1 ms | 256 KB | Output is correct |
96 | Correct | 1 ms | 256 KB | Output is correct |
97 | Correct | 25 ms | 3328 KB | Output is correct |
98 | Correct | 101 ms | 12152 KB | Output is correct |
99 | Correct | 103 ms | 12152 KB | Output is correct |
100 | Correct | 103 ms | 12156 KB | Output is correct |
101 | Correct | 102 ms | 12152 KB | Output is correct |
102 | Correct | 115 ms | 12152 KB | Output is correct |
103 | Correct | 112 ms | 12152 KB | Output is correct |
104 | Correct | 108 ms | 12280 KB | Output is correct |
105 | Correct | 112 ms | 12152 KB | Output is correct |