# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642941 | 2022-09-20T22:27:28 Z | _petar_b | Connecting Supertrees (IOI20_supertrees) | C++14 | 219 ms | 24056 KB |
#include "supertrees.h" #include <bits/stdc++.h> #define MAXN 1010 using namespace std; int graph[MAXN], graph_count = 1, krak[MAXN]; int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n, 0); answer.push_back(row); } // for (int i = 0; i < n; i++) { if (graph[i] == 0) graph[i] = graph_count++;; for (int j = 0; j < n; j++) { if (p[i][j] == 3) return 0; if (p[i][j]) { if (graph[j] != 0 && graph[j] != graph[i]) return 0; graph[j] = graph[i]; } else if (graph[i] == graph[j]) return 0; } } // vector<vector<int>> kraci; vector<int> empt; kraci.push_back(empt); vector<vector<int>> ciklusi; ciklusi.resize(graph_count); for (int i = 0 ; i < n; i++) { bool all2 = true, all0 = true; for (int j = 0; j < n; j++) if (j != i && graph[i] == graph[j]) { if (p[i][j] == 2) all0 = false; if (p[i][j] == 1) { all2 = false; all0 = false; if (krak[i] == 0) { krak[i] = krak[j]; } else if (krak[j] != 0 && krak[i] != krak[j]) return 0; } } if (all0) ; else if (all2) { ciklusi[graph[i]].push_back(i); } else { if (krak[i] == 0) { kraci.push_back(empt); kraci[kraci.size()-1].push_back(i); krak[i] = kraci.size() - 1; ciklusi[graph[i]].push_back(i); } else kraci[krak[i]].push_back(i); } } //povezivanje ciklusa for (int i = 1; i < graph_count; i++) if (!ciklusi[i].empty()) { if (ciklusi[i].size() == 1) ; else if (ciklusi[i].size() == 2) return 0; else { int last = ciklusi[i][0]; for (int j = 1; j < ciklusi[i].size(); j++) { answer[last][ciklusi[i][j]] = 1; answer[ciklusi[i][j]][last] = 1; last = ciklusi[i][j]; } answer[ciklusi[i][0]][last] = 1; answer[last][ciklusi[i][0]] = 1; } } //povezivanje krakova for (int i = 1; i < kraci.size(); i++) { for (int j = 1; j < kraci[i].size(); j++) { answer[kraci[i][j-1]][kraci[i][j]] = 1; answer[kraci[i][j]][kraci[i][j-1]] = 1; } } build(answer); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1196 KB | Output is correct |
7 | Correct | 187 ms | 22024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1196 KB | Output is correct |
7 | Correct | 187 ms | 22024 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 7 ms | 1108 KB | Output is correct |
13 | Correct | 179 ms | 22020 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 724 KB | Output is correct |
17 | Correct | 69 ms | 12052 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 44 ms | 6220 KB | Output is correct |
21 | Correct | 183 ms | 23940 KB | Output is correct |
22 | Correct | 171 ms | 24056 KB | Output is correct |
23 | Correct | 192 ms | 23924 KB | Output is correct |
24 | Correct | 166 ms | 23920 KB | Output is correct |
25 | Correct | 72 ms | 14084 KB | Output is correct |
26 | Correct | 65 ms | 14028 KB | Output is correct |
27 | Correct | 185 ms | 23936 KB | Output is correct |
28 | Correct | 170 ms | 24032 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 8 ms | 1108 KB | Output is correct |
9 | Correct | 169 ms | 22084 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 8 ms | 1188 KB | Output is correct |
13 | Correct | 219 ms | 22036 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 724 KB | Output is correct |
17 | Correct | 72 ms | 12036 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 46 ms | 5728 KB | Output is correct |
22 | Correct | 169 ms | 22092 KB | Output is correct |
23 | Correct | 166 ms | 22040 KB | Output is correct |
24 | Correct | 193 ms | 22020 KB | Output is correct |
25 | Correct | 63 ms | 12048 KB | Output is correct |
26 | Correct | 66 ms | 12040 KB | Output is correct |
27 | Correct | 176 ms | 22032 KB | Output is correct |
28 | Correct | 179 ms | 22032 KB | Output is correct |
29 | Correct | 66 ms | 12164 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 45 ms | 5764 KB | Output is correct |
5 | Correct | 188 ms | 21996 KB | Output is correct |
6 | Correct | 182 ms | 22032 KB | Output is correct |
7 | Correct | 199 ms | 21976 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 49 ms | 5760 KB | Output is correct |
10 | Correct | 175 ms | 22024 KB | Output is correct |
11 | Correct | 183 ms | 22036 KB | Output is correct |
12 | Correct | 209 ms | 21980 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 44 ms | 5680 KB | Output is correct |
17 | Correct | 180 ms | 22028 KB | Output is correct |
18 | Correct | 179 ms | 22028 KB | Output is correct |
19 | Correct | 198 ms | 22076 KB | Output is correct |
20 | Correct | 173 ms | 22032 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1196 KB | Output is correct |
7 | Correct | 187 ms | 22024 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 7 ms | 1108 KB | Output is correct |
13 | Correct | 179 ms | 22020 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 724 KB | Output is correct |
17 | Correct | 69 ms | 12052 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 44 ms | 6220 KB | Output is correct |
21 | Correct | 183 ms | 23940 KB | Output is correct |
22 | Correct | 171 ms | 24056 KB | Output is correct |
23 | Correct | 192 ms | 23924 KB | Output is correct |
24 | Correct | 166 ms | 23920 KB | Output is correct |
25 | Correct | 72 ms | 14084 KB | Output is correct |
26 | Correct | 65 ms | 14028 KB | Output is correct |
27 | Correct | 185 ms | 23936 KB | Output is correct |
28 | Correct | 170 ms | 24032 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 0 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 212 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 8 ms | 1108 KB | Output is correct |
37 | Correct | 169 ms | 22084 KB | Output is correct |
38 | Correct | 0 ms | 212 KB | Output is correct |
39 | Correct | 0 ms | 212 KB | Output is correct |
40 | Correct | 8 ms | 1188 KB | Output is correct |
41 | Correct | 219 ms | 22036 KB | Output is correct |
42 | Correct | 0 ms | 212 KB | Output is correct |
43 | Correct | 0 ms | 212 KB | Output is correct |
44 | Correct | 3 ms | 724 KB | Output is correct |
45 | Correct | 72 ms | 12036 KB | Output is correct |
46 | Correct | 0 ms | 212 KB | Output is correct |
47 | Correct | 0 ms | 212 KB | Output is correct |
48 | Correct | 1 ms | 212 KB | Output is correct |
49 | Correct | 46 ms | 5728 KB | Output is correct |
50 | Correct | 169 ms | 22092 KB | Output is correct |
51 | Correct | 166 ms | 22040 KB | Output is correct |
52 | Correct | 193 ms | 22020 KB | Output is correct |
53 | Correct | 63 ms | 12048 KB | Output is correct |
54 | Correct | 66 ms | 12040 KB | Output is correct |
55 | Correct | 176 ms | 22032 KB | Output is correct |
56 | Correct | 179 ms | 22032 KB | Output is correct |
57 | Correct | 66 ms | 12164 KB | Output is correct |
58 | Correct | 0 ms | 212 KB | Output is correct |
59 | Correct | 1 ms | 212 KB | Output is correct |
60 | Correct | 4 ms | 852 KB | Output is correct |
61 | Correct | 72 ms | 14084 KB | Output is correct |
62 | Correct | 0 ms | 212 KB | Output is correct |
63 | Correct | 0 ms | 212 KB | Output is correct |
64 | Correct | 1 ms | 212 KB | Output is correct |
65 | Correct | 45 ms | 6216 KB | Output is correct |
66 | Correct | 65 ms | 14072 KB | Output is correct |
67 | Correct | 67 ms | 14072 KB | Output is correct |
68 | Correct | 91 ms | 14072 KB | Output is correct |
69 | Correct | 90 ms | 14028 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1196 KB | Output is correct |
7 | Correct | 187 ms | 22024 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 7 ms | 1108 KB | Output is correct |
13 | Correct | 179 ms | 22020 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 724 KB | Output is correct |
17 | Correct | 69 ms | 12052 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 44 ms | 6220 KB | Output is correct |
21 | Correct | 183 ms | 23940 KB | Output is correct |
22 | Correct | 171 ms | 24056 KB | Output is correct |
23 | Correct | 192 ms | 23924 KB | Output is correct |
24 | Correct | 166 ms | 23920 KB | Output is correct |
25 | Correct | 72 ms | 14084 KB | Output is correct |
26 | Correct | 65 ms | 14028 KB | Output is correct |
27 | Correct | 185 ms | 23936 KB | Output is correct |
28 | Correct | 170 ms | 24032 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 0 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 212 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 8 ms | 1108 KB | Output is correct |
37 | Correct | 169 ms | 22084 KB | Output is correct |
38 | Correct | 0 ms | 212 KB | Output is correct |
39 | Correct | 0 ms | 212 KB | Output is correct |
40 | Correct | 8 ms | 1188 KB | Output is correct |
41 | Correct | 219 ms | 22036 KB | Output is correct |
42 | Correct | 0 ms | 212 KB | Output is correct |
43 | Correct | 0 ms | 212 KB | Output is correct |
44 | Correct | 3 ms | 724 KB | Output is correct |
45 | Correct | 72 ms | 12036 KB | Output is correct |
46 | Correct | 0 ms | 212 KB | Output is correct |
47 | Correct | 0 ms | 212 KB | Output is correct |
48 | Correct | 1 ms | 212 KB | Output is correct |
49 | Correct | 46 ms | 5728 KB | Output is correct |
50 | Correct | 169 ms | 22092 KB | Output is correct |
51 | Correct | 166 ms | 22040 KB | Output is correct |
52 | Correct | 193 ms | 22020 KB | Output is correct |
53 | Correct | 63 ms | 12048 KB | Output is correct |
54 | Correct | 66 ms | 12040 KB | Output is correct |
55 | Correct | 176 ms | 22032 KB | Output is correct |
56 | Correct | 179 ms | 22032 KB | Output is correct |
57 | Correct | 66 ms | 12164 KB | Output is correct |
58 | Correct | 1 ms | 212 KB | Output is correct |
59 | Correct | 1 ms | 212 KB | Output is correct |
60 | Correct | 1 ms | 212 KB | Output is correct |
61 | Correct | 45 ms | 5764 KB | Output is correct |
62 | Correct | 188 ms | 21996 KB | Output is correct |
63 | Correct | 182 ms | 22032 KB | Output is correct |
64 | Correct | 199 ms | 21976 KB | Output is correct |
65 | Correct | 0 ms | 212 KB | Output is correct |
66 | Correct | 49 ms | 5760 KB | Output is correct |
67 | Correct | 175 ms | 22024 KB | Output is correct |
68 | Correct | 183 ms | 22036 KB | Output is correct |
69 | Correct | 209 ms | 21980 KB | Output is correct |
70 | Correct | 0 ms | 212 KB | Output is correct |
71 | Correct | 0 ms | 212 KB | Output is correct |
72 | Correct | 0 ms | 212 KB | Output is correct |
73 | Correct | 44 ms | 5680 KB | Output is correct |
74 | Correct | 180 ms | 22028 KB | Output is correct |
75 | Correct | 179 ms | 22028 KB | Output is correct |
76 | Correct | 198 ms | 22076 KB | Output is correct |
77 | Correct | 173 ms | 22032 KB | Output is correct |
78 | Correct | 0 ms | 212 KB | Output is correct |
79 | Correct | 1 ms | 212 KB | Output is correct |
80 | Correct | 4 ms | 852 KB | Output is correct |
81 | Correct | 72 ms | 14084 KB | Output is correct |
82 | Correct | 0 ms | 212 KB | Output is correct |
83 | Correct | 0 ms | 212 KB | Output is correct |
84 | Correct | 1 ms | 212 KB | Output is correct |
85 | Correct | 45 ms | 6216 KB | Output is correct |
86 | Correct | 65 ms | 14072 KB | Output is correct |
87 | Correct | 67 ms | 14072 KB | Output is correct |
88 | Correct | 91 ms | 14072 KB | Output is correct |
89 | Correct | 90 ms | 14028 KB | Output is correct |
90 | Correct | 0 ms | 212 KB | Output is correct |
91 | Correct | 0 ms | 300 KB | Output is correct |
92 | Correct | 3 ms | 852 KB | Output is correct |
93 | Correct | 72 ms | 14072 KB | Output is correct |
94 | Correct | 0 ms | 300 KB | Output is correct |
95 | Correct | 1 ms | 212 KB | Output is correct |
96 | Correct | 1 ms | 212 KB | Output is correct |
97 | Correct | 21 ms | 3696 KB | Output is correct |
98 | Correct | 66 ms | 14020 KB | Output is correct |
99 | Correct | 79 ms | 14072 KB | Output is correct |
100 | Correct | 68 ms | 14084 KB | Output is correct |
101 | Correct | 64 ms | 14080 KB | Output is correct |
102 | Correct | 66 ms | 14084 KB | Output is correct |
103 | Correct | 70 ms | 14072 KB | Output is correct |
104 | Correct | 71 ms | 14076 KB | Output is correct |
105 | Correct | 72 ms | 14080 KB | Output is correct |