# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
432350 | 2021-06-18T08:26:45 Z | arayi | Connecting Supertrees (IOI20_supertrees) | C++17 | 261 ms | 22276 KB |
#include "supertrees.h" #include <bits/stdc++.h> #define ad push_back using namespace std; const int N = 1111; int col[N], sm[N], i1 = 1; vector <vector <int> > b; vector<int> g[N]; int n; void dfs(int v) { col[v] = 2; sm[v]++; for(auto p : g[v]) if(col[p] != 2) dfs(p); col[v] = 1; } int construct(std::vector<std::vector<int>> p) { n = p.size(); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if(p[i][j] >= 3) return 0; for (int i = 0; i < n; i++) { if(sm[i]) { for (int j = 0; j < n; j++) { if(p[i][j] && sm[i] != sm[j]) return 0; if(p[i][j] == 0 && sm[i] == sm[j]) return 0; } } else { for (int j = 0; j < n; j++) { if(p[i][j] && sm[j]) return 0; if(p[i][j]) sm[j] = i1; } } i1++; } b.resize(n); for (int i = 0; i < n; i++) b[i].resize(n); for (int i = 1; i < i1; i++) { vector<int> fp; for (int j = 0; j < n; j++) if(sm[j] == i) fp.ad(j); int nx = -1; for (int j = 0; j < fp.size(); j++) { if(col[fp[j]]) continue; if(nx != -1) b[nx][fp[j]] = b[fp[j]][nx] = 1; nx = fp[j]; col[fp[j]] = 1; for (int k = j + 1; k < fp.size(); k++) if(p[fp[j]][fp[k]] == 1) b[fp[j]][fp[k]] = b[fp[k]][fp[j]] = 1, col[fp[k]] = 1; } if(nx != -1 && nx != fp[0]) b[nx][fp[0]] = b[fp[0]][nx] = 1; } for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if(b[i][j]) g[i].ad(j); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) sm[j] = col[j] = 0; dfs(i); for (int j = 0; j < n; j++) if(sm[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 | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 10 ms | 1200 KB | Output is correct |
7 | Correct | 240 ms | 22028 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 10 ms | 1200 KB | Output is correct |
7 | Correct | 240 ms | 22028 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 10 ms | 1100 KB | Output is correct |
13 | Correct | 231 ms | 22032 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 4 ms | 588 KB | Output is correct |
17 | Correct | 98 ms | 8084 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 58 ms | 5784 KB | Output is correct |
21 | Correct | 230 ms | 22212 KB | Output is correct |
22 | Correct | 229 ms | 22100 KB | Output is correct |
23 | Correct | 239 ms | 22040 KB | Output is correct |
24 | Correct | 239 ms | 22036 KB | Output is correct |
25 | Correct | 90 ms | 8096 KB | Output is correct |
26 | Correct | 89 ms | 8088 KB | Output is correct |
27 | Correct | 241 ms | 22044 KB | Output is correct |
28 | Correct | 230 ms | 22104 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 | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 10 ms | 1120 KB | Output is correct |
9 | Correct | 231 ms | 22040 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 10 ms | 1196 KB | Output is correct |
13 | Correct | 250 ms | 22276 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
16 | Correct | 5 ms | 608 KB | Output is correct |
17 | Correct | 94 ms | 8132 KB | Output is correct |
18 | Correct | 0 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 0 ms | 204 KB | Output is correct |
21 | Correct | 59 ms | 5764 KB | Output is correct |
22 | Correct | 243 ms | 22004 KB | Output is correct |
23 | Correct | 235 ms | 22020 KB | Output is correct |
24 | Correct | 246 ms | 22084 KB | Output is correct |
25 | Correct | 97 ms | 12100 KB | Output is correct |
26 | Correct | 90 ms | 8096 KB | Output is correct |
27 | Correct | 252 ms | 22112 KB | Output is correct |
28 | Correct | 261 ms | 22028 KB | Output is correct |
29 | Correct | 101 ms | 12068 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 60 ms | 5800 KB | Output is correct |
5 | Correct | 232 ms | 22056 KB | Output is correct |
6 | Correct | 230 ms | 22084 KB | Output is correct |
7 | Correct | 256 ms | 22040 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 62 ms | 5740 KB | Output is correct |
10 | Correct | 238 ms | 22176 KB | Output is correct |
11 | Correct | 229 ms | 22176 KB | Output is correct |
12 | Correct | 250 ms | 22020 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 | 58 ms | 5788 KB | Output is correct |
17 | Correct | 234 ms | 22100 KB | Output is correct |
18 | Correct | 239 ms | 22072 KB | Output is correct |
19 | Correct | 227 ms | 22088 KB | Output is correct |
20 | Correct | 235 ms | 22076 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 10 ms | 1200 KB | Output is correct |
7 | Correct | 240 ms | 22028 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 10 ms | 1100 KB | Output is correct |
13 | Correct | 231 ms | 22032 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 4 ms | 588 KB | Output is correct |
17 | Correct | 98 ms | 8084 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 58 ms | 5784 KB | Output is correct |
21 | Correct | 230 ms | 22212 KB | Output is correct |
22 | Correct | 229 ms | 22100 KB | Output is correct |
23 | Correct | 239 ms | 22040 KB | Output is correct |
24 | Correct | 239 ms | 22036 KB | Output is correct |
25 | Correct | 90 ms | 8096 KB | Output is correct |
26 | Correct | 89 ms | 8088 KB | Output is correct |
27 | Correct | 241 ms | 22044 KB | Output is correct |
28 | Correct | 230 ms | 22104 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 | 204 KB | Output is correct |
34 | Correct | 0 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 204 KB | Output is correct |
36 | Correct | 10 ms | 1120 KB | Output is correct |
37 | Correct | 231 ms | 22040 KB | Output is correct |
38 | Correct | 1 ms | 204 KB | Output is correct |
39 | Correct | 1 ms | 204 KB | Output is correct |
40 | Correct | 10 ms | 1196 KB | Output is correct |
41 | Correct | 250 ms | 22276 KB | Output is correct |
42 | Correct | 1 ms | 204 KB | Output is correct |
43 | Correct | 0 ms | 204 KB | Output is correct |
44 | Correct | 5 ms | 608 KB | Output is correct |
45 | Correct | 94 ms | 8132 KB | Output is correct |
46 | Correct | 0 ms | 204 KB | Output is correct |
47 | Correct | 1 ms | 204 KB | Output is correct |
48 | Correct | 0 ms | 204 KB | Output is correct |
49 | Correct | 59 ms | 5764 KB | Output is correct |
50 | Correct | 243 ms | 22004 KB | Output is correct |
51 | Correct | 235 ms | 22020 KB | Output is correct |
52 | Correct | 246 ms | 22084 KB | Output is correct |
53 | Correct | 97 ms | 12100 KB | Output is correct |
54 | Correct | 90 ms | 8096 KB | Output is correct |
55 | Correct | 252 ms | 22112 KB | Output is correct |
56 | Correct | 261 ms | 22028 KB | Output is correct |
57 | Correct | 101 ms | 12068 KB | Output is correct |
58 | Correct | 1 ms | 204 KB | Output is correct |
59 | Correct | 0 ms | 204 KB | Output is correct |
60 | Correct | 4 ms | 588 KB | Output is correct |
61 | Correct | 102 ms | 8084 KB | Output is correct |
62 | Correct | 1 ms | 204 KB | Output is correct |
63 | Correct | 1 ms | 204 KB | Output is correct |
64 | Correct | 1 ms | 204 KB | Output is correct |
65 | Correct | 67 ms | 5732 KB | Output is correct |
66 | Correct | 115 ms | 8084 KB | Output is correct |
67 | Correct | 98 ms | 8096 KB | Output is correct |
68 | Correct | 94 ms | 8088 KB | Output is correct |
69 | Correct | 109 ms | 12056 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 10 ms | 1200 KB | Output is correct |
7 | Correct | 240 ms | 22028 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 10 ms | 1100 KB | Output is correct |
13 | Correct | 231 ms | 22032 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 4 ms | 588 KB | Output is correct |
17 | Correct | 98 ms | 8084 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 58 ms | 5784 KB | Output is correct |
21 | Correct | 230 ms | 22212 KB | Output is correct |
22 | Correct | 229 ms | 22100 KB | Output is correct |
23 | Correct | 239 ms | 22040 KB | Output is correct |
24 | Correct | 239 ms | 22036 KB | Output is correct |
25 | Correct | 90 ms | 8096 KB | Output is correct |
26 | Correct | 89 ms | 8088 KB | Output is correct |
27 | Correct | 241 ms | 22044 KB | Output is correct |
28 | Correct | 230 ms | 22104 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 | 204 KB | Output is correct |
34 | Correct | 0 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 204 KB | Output is correct |
36 | Correct | 10 ms | 1120 KB | Output is correct |
37 | Correct | 231 ms | 22040 KB | Output is correct |
38 | Correct | 1 ms | 204 KB | Output is correct |
39 | Correct | 1 ms | 204 KB | Output is correct |
40 | Correct | 10 ms | 1196 KB | Output is correct |
41 | Correct | 250 ms | 22276 KB | Output is correct |
42 | Correct | 1 ms | 204 KB | Output is correct |
43 | Correct | 0 ms | 204 KB | Output is correct |
44 | Correct | 5 ms | 608 KB | Output is correct |
45 | Correct | 94 ms | 8132 KB | Output is correct |
46 | Correct | 0 ms | 204 KB | Output is correct |
47 | Correct | 1 ms | 204 KB | Output is correct |
48 | Correct | 0 ms | 204 KB | Output is correct |
49 | Correct | 59 ms | 5764 KB | Output is correct |
50 | Correct | 243 ms | 22004 KB | Output is correct |
51 | Correct | 235 ms | 22020 KB | Output is correct |
52 | Correct | 246 ms | 22084 KB | Output is correct |
53 | Correct | 97 ms | 12100 KB | Output is correct |
54 | Correct | 90 ms | 8096 KB | Output is correct |
55 | Correct | 252 ms | 22112 KB | Output is correct |
56 | Correct | 261 ms | 22028 KB | Output is correct |
57 | Correct | 101 ms | 12068 KB | Output is correct |
58 | Correct | 0 ms | 204 KB | Output is correct |
59 | Correct | 0 ms | 204 KB | Output is correct |
60 | Correct | 1 ms | 204 KB | Output is correct |
61 | Correct | 60 ms | 5800 KB | Output is correct |
62 | Correct | 232 ms | 22056 KB | Output is correct |
63 | Correct | 230 ms | 22084 KB | Output is correct |
64 | Correct | 256 ms | 22040 KB | Output is correct |
65 | Correct | 0 ms | 204 KB | Output is correct |
66 | Correct | 62 ms | 5740 KB | Output is correct |
67 | Correct | 238 ms | 22176 KB | Output is correct |
68 | Correct | 229 ms | 22176 KB | Output is correct |
69 | Correct | 250 ms | 22020 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 | 58 ms | 5788 KB | Output is correct |
74 | Correct | 234 ms | 22100 KB | Output is correct |
75 | Correct | 239 ms | 22072 KB | Output is correct |
76 | Correct | 227 ms | 22088 KB | Output is correct |
77 | Correct | 235 ms | 22076 KB | Output is correct |
78 | Correct | 1 ms | 204 KB | Output is correct |
79 | Correct | 0 ms | 204 KB | Output is correct |
80 | Correct | 4 ms | 588 KB | Output is correct |
81 | Correct | 102 ms | 8084 KB | Output is correct |
82 | Correct | 1 ms | 204 KB | Output is correct |
83 | Correct | 1 ms | 204 KB | Output is correct |
84 | Correct | 1 ms | 204 KB | Output is correct |
85 | Correct | 67 ms | 5732 KB | Output is correct |
86 | Correct | 115 ms | 8084 KB | Output is correct |
87 | Correct | 98 ms | 8096 KB | Output is correct |
88 | Correct | 94 ms | 8088 KB | Output is correct |
89 | Correct | 109 ms | 12056 KB | Output is correct |
90 | Correct | 1 ms | 204 KB | Output is correct |
91 | Correct | 1 ms | 204 KB | Output is correct |
92 | Correct | 5 ms | 612 KB | Output is correct |
93 | Correct | 104 ms | 8092 KB | Output is correct |
94 | Correct | 0 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 | 24 ms | 2184 KB | Output is correct |
98 | Correct | 96 ms | 8088 KB | Output is correct |
99 | Correct | 91 ms | 8088 KB | Output is correct |
100 | Correct | 93 ms | 8132 KB | Output is correct |
101 | Correct | 98 ms | 8088 KB | Output is correct |
102 | Correct | 91 ms | 8088 KB | Output is correct |
103 | Correct | 99 ms | 8084 KB | Output is correct |
104 | Correct | 98 ms | 8096 KB | Output is correct |
105 | Correct | 100 ms | 10128 KB | Output is correct |