# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
386037 | 2021-04-05T13:19:02 Z | AdOjis485 | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 294 ms | 28240 KB |
#include "supertrees.h" #include <vector> #include <iostream> #include <map> using namespace std; int construct(vector<vector<int>> p) { int n = p.size(); map<vector<int>, int> m; vector<vector<int> > parts; for(int i = 0; i < n; i ++) { if(m.count(p[i]) == 0) { m[p[i]] = m.size(); parts.push_back({i}); } else parts[m[p[i]]].push_back(i); } vector<bool> done(n); vector<vector<int> > answer(n, vector<int> (n)); cerr << "parts:\n"; for(auto part : parts) { for(auto el : part) cerr << el << " "; cerr << '\n'; } bool poss = true; for(int i = 0; i < n; i ++) { int numparts = 0; vector<int> comp; if(done[i]) continue; int last = -1; int first = -1; int compsizei = 0; for(int j = 0; j < n; j ++) compsizei += (p[i][j] > 0); for(int j = 0; j < parts.size(); j ++) { if(p[i][parts[j][0]] == 0) continue; numparts ++; if(first < 0) first = parts[j][0]; int compsizecur = 0; for(int el : p[parts[j][0]]) compsizecur += (el > 0); if(compsizecur != compsizei) poss = false; for(int k = 0; k < parts[j].size(); k ++) { int cur = parts[j][k]; done[cur] = true; comp.push_back(cur); if(k == 0) { if(last >= 0) { answer[cur][last] = 1; answer[last][cur] = 1; } } else { answer[cur][parts[j][k - 1]] = 1; answer[parts[j][k - 1]][cur] = 1; } } last = parts[j][0]; } if(last != first) { answer[first][last] = 1; answer[last][first] = 1; } for(int a : comp) { for(int b : comp) if(p[a][b] == 0) poss = false; } if(comp.size() != compsizei) poss = false; if(numparts == 2) poss = false; } for(auto part : parts) { int count = 0; for(auto el : p[part[0]]) count += el % 2; poss &= (count == part.size()); } if(poss) { build(answer); return 1; } else return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 11 ms | 1260 KB | Output is correct |
7 | Correct | 250 ms | 22124 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 11 ms | 1260 KB | Output is correct |
7 | Correct | 250 ms | 22124 KB | Output is correct |
8 | Correct | 2 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 2 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 13 ms | 1388 KB | Output is correct |
13 | Correct | 269 ms | 26220 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 9 ms | 1004 KB | Output is correct |
17 | Correct | 128 ms | 16236 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 2 ms | 364 KB | Output is correct |
20 | Correct | 82 ms | 5996 KB | Output is correct |
21 | Correct | 248 ms | 22252 KB | Output is correct |
22 | Correct | 258 ms | 23788 KB | Output is correct |
23 | Correct | 257 ms | 22124 KB | Output is correct |
24 | Correct | 268 ms | 25964 KB | Output is correct |
25 | Correct | 111 ms | 12268 KB | Output is correct |
26 | Correct | 120 ms | 13804 KB | Output is correct |
27 | Correct | 260 ms | 22124 KB | Output is correct |
28 | Correct | 270 ms | 25964 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 2 ms | 364 KB | Output is correct |
8 | Correct | 13 ms | 1516 KB | Output is correct |
9 | Correct | 281 ms | 28240 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 13 ms | 1516 KB | Output is correct |
13 | Correct | 267 ms | 28140 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 3 ms | 364 KB | Output is correct |
16 | Correct | 7 ms | 1132 KB | Output is correct |
17 | Correct | 162 ms | 18156 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 66 ms | 7404 KB | Output is correct |
22 | Correct | 263 ms | 28140 KB | Output is correct |
23 | Correct | 256 ms | 28140 KB | Output is correct |
24 | Correct | 272 ms | 28140 KB | Output is correct |
25 | Correct | 134 ms | 18156 KB | Output is correct |
26 | Correct | 124 ms | 18284 KB | Output is correct |
27 | Correct | 257 ms | 27756 KB | Output is correct |
28 | Correct | 294 ms | 28140 KB | Output is correct |
29 | Correct | 134 ms | 18284 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 65 ms | 5996 KB | Output is correct |
5 | Correct | 249 ms | 22124 KB | Output is correct |
6 | Correct | 252 ms | 23916 KB | Output is correct |
7 | Correct | 252 ms | 22124 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 68 ms | 6892 KB | Output is correct |
10 | Correct | 258 ms | 26348 KB | Output is correct |
11 | Correct | 257 ms | 26220 KB | Output is correct |
12 | Correct | 270 ms | 26220 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 66 ms | 6764 KB | Output is correct |
17 | Correct | 257 ms | 26220 KB | Output is correct |
18 | Correct | 264 ms | 24300 KB | Output is correct |
19 | Correct | 251 ms | 24556 KB | Output is correct |
20 | Correct | 272 ms | 26092 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 11 ms | 1260 KB | Output is correct |
7 | Correct | 250 ms | 22124 KB | Output is correct |
8 | Correct | 2 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 2 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 13 ms | 1388 KB | Output is correct |
13 | Correct | 269 ms | 26220 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 9 ms | 1004 KB | Output is correct |
17 | Correct | 128 ms | 16236 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 2 ms | 364 KB | Output is correct |
20 | Correct | 82 ms | 5996 KB | Output is correct |
21 | Correct | 248 ms | 22252 KB | Output is correct |
22 | Correct | 258 ms | 23788 KB | Output is correct |
23 | Correct | 257 ms | 22124 KB | Output is correct |
24 | Correct | 268 ms | 25964 KB | Output is correct |
25 | Correct | 111 ms | 12268 KB | Output is correct |
26 | Correct | 120 ms | 13804 KB | Output is correct |
27 | Correct | 260 ms | 22124 KB | Output is correct |
28 | Correct | 270 ms | 25964 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 1 ms | 364 KB | Output is correct |
32 | Correct | 1 ms | 364 KB | Output is correct |
33 | Correct | 1 ms | 364 KB | Output is correct |
34 | Correct | 1 ms | 364 KB | Output is correct |
35 | Correct | 2 ms | 364 KB | Output is correct |
36 | Correct | 13 ms | 1516 KB | Output is correct |
37 | Correct | 281 ms | 28240 KB | Output is correct |
38 | Correct | 1 ms | 364 KB | Output is correct |
39 | Correct | 1 ms | 364 KB | Output is correct |
40 | Correct | 13 ms | 1516 KB | Output is correct |
41 | Correct | 267 ms | 28140 KB | Output is correct |
42 | Correct | 1 ms | 364 KB | Output is correct |
43 | Correct | 3 ms | 364 KB | Output is correct |
44 | Correct | 7 ms | 1132 KB | Output is correct |
45 | Correct | 162 ms | 18156 KB | Output is correct |
46 | Correct | 1 ms | 364 KB | Output is correct |
47 | Correct | 1 ms | 364 KB | Output is correct |
48 | Correct | 1 ms | 364 KB | Output is correct |
49 | Correct | 66 ms | 7404 KB | Output is correct |
50 | Correct | 263 ms | 28140 KB | Output is correct |
51 | Correct | 256 ms | 28140 KB | Output is correct |
52 | Correct | 272 ms | 28140 KB | Output is correct |
53 | Correct | 134 ms | 18156 KB | Output is correct |
54 | Correct | 124 ms | 18284 KB | Output is correct |
55 | Correct | 257 ms | 27756 KB | Output is correct |
56 | Correct | 294 ms | 28140 KB | Output is correct |
57 | Correct | 134 ms | 18284 KB | Output is correct |
58 | Correct | 1 ms | 364 KB | Output is correct |
59 | Correct | 2 ms | 364 KB | Output is correct |
60 | Correct | 7 ms | 1132 KB | Output is correct |
61 | Correct | 127 ms | 18284 KB | Output is correct |
62 | Correct | 1 ms | 364 KB | Output is correct |
63 | Correct | 1 ms | 364 KB | Output is correct |
64 | Correct | 2 ms | 364 KB | Output is correct |
65 | Correct | 66 ms | 7148 KB | Output is correct |
66 | Correct | 124 ms | 18256 KB | Output is correct |
67 | Correct | 121 ms | 16876 KB | Output is correct |
68 | Correct | 119 ms | 16364 KB | Output is correct |
69 | Correct | 146 ms | 18028 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 11 ms | 1260 KB | Output is correct |
7 | Correct | 250 ms | 22124 KB | Output is correct |
8 | Correct | 2 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 2 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 13 ms | 1388 KB | Output is correct |
13 | Correct | 269 ms | 26220 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 9 ms | 1004 KB | Output is correct |
17 | Correct | 128 ms | 16236 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 2 ms | 364 KB | Output is correct |
20 | Correct | 82 ms | 5996 KB | Output is correct |
21 | Correct | 248 ms | 22252 KB | Output is correct |
22 | Correct | 258 ms | 23788 KB | Output is correct |
23 | Correct | 257 ms | 22124 KB | Output is correct |
24 | Correct | 268 ms | 25964 KB | Output is correct |
25 | Correct | 111 ms | 12268 KB | Output is correct |
26 | Correct | 120 ms | 13804 KB | Output is correct |
27 | Correct | 260 ms | 22124 KB | Output is correct |
28 | Correct | 270 ms | 25964 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 1 ms | 364 KB | Output is correct |
32 | Correct | 1 ms | 364 KB | Output is correct |
33 | Correct | 1 ms | 364 KB | Output is correct |
34 | Correct | 1 ms | 364 KB | Output is correct |
35 | Correct | 2 ms | 364 KB | Output is correct |
36 | Correct | 13 ms | 1516 KB | Output is correct |
37 | Correct | 281 ms | 28240 KB | Output is correct |
38 | Correct | 1 ms | 364 KB | Output is correct |
39 | Correct | 1 ms | 364 KB | Output is correct |
40 | Correct | 13 ms | 1516 KB | Output is correct |
41 | Correct | 267 ms | 28140 KB | Output is correct |
42 | Correct | 1 ms | 364 KB | Output is correct |
43 | Correct | 3 ms | 364 KB | Output is correct |
44 | Correct | 7 ms | 1132 KB | Output is correct |
45 | Correct | 162 ms | 18156 KB | Output is correct |
46 | Correct | 1 ms | 364 KB | Output is correct |
47 | Correct | 1 ms | 364 KB | Output is correct |
48 | Correct | 1 ms | 364 KB | Output is correct |
49 | Correct | 66 ms | 7404 KB | Output is correct |
50 | Correct | 263 ms | 28140 KB | Output is correct |
51 | Correct | 256 ms | 28140 KB | Output is correct |
52 | Correct | 272 ms | 28140 KB | Output is correct |
53 | Correct | 134 ms | 18156 KB | Output is correct |
54 | Correct | 124 ms | 18284 KB | Output is correct |
55 | Correct | 257 ms | 27756 KB | Output is correct |
56 | Correct | 294 ms | 28140 KB | Output is correct |
57 | Correct | 134 ms | 18284 KB | Output is correct |
58 | Correct | 1 ms | 364 KB | Output is correct |
59 | Correct | 1 ms | 364 KB | Output is correct |
60 | Correct | 1 ms | 364 KB | Output is correct |
61 | Correct | 65 ms | 5996 KB | Output is correct |
62 | Correct | 249 ms | 22124 KB | Output is correct |
63 | Correct | 252 ms | 23916 KB | Output is correct |
64 | Correct | 252 ms | 22124 KB | Output is correct |
65 | Correct | 1 ms | 364 KB | Output is correct |
66 | Correct | 68 ms | 6892 KB | Output is correct |
67 | Correct | 258 ms | 26348 KB | Output is correct |
68 | Correct | 257 ms | 26220 KB | Output is correct |
69 | Correct | 270 ms | 26220 KB | Output is correct |
70 | Correct | 1 ms | 364 KB | Output is correct |
71 | Correct | 1 ms | 364 KB | Output is correct |
72 | Correct | 1 ms | 364 KB | Output is correct |
73 | Correct | 66 ms | 6764 KB | Output is correct |
74 | Correct | 257 ms | 26220 KB | Output is correct |
75 | Correct | 264 ms | 24300 KB | Output is correct |
76 | Correct | 251 ms | 24556 KB | Output is correct |
77 | Correct | 272 ms | 26092 KB | Output is correct |
78 | Correct | 1 ms | 364 KB | Output is correct |
79 | Correct | 2 ms | 364 KB | Output is correct |
80 | Correct | 7 ms | 1132 KB | Output is correct |
81 | Correct | 127 ms | 18284 KB | Output is correct |
82 | Correct | 1 ms | 364 KB | Output is correct |
83 | Correct | 1 ms | 364 KB | Output is correct |
84 | Correct | 2 ms | 364 KB | Output is correct |
85 | Correct | 66 ms | 7148 KB | Output is correct |
86 | Correct | 124 ms | 18256 KB | Output is correct |
87 | Correct | 121 ms | 16876 KB | Output is correct |
88 | Correct | 119 ms | 16364 KB | Output is correct |
89 | Correct | 146 ms | 18028 KB | Output is correct |
90 | Correct | 1 ms | 364 KB | Output is correct |
91 | Correct | 1 ms | 364 KB | Output is correct |
92 | Correct | 7 ms | 1132 KB | Output is correct |
93 | Correct | 124 ms | 18156 KB | Output is correct |
94 | Correct | 1 ms | 364 KB | Output is correct |
95 | Correct | 1 ms | 388 KB | Output is correct |
96 | Correct | 1 ms | 364 KB | Output is correct |
97 | Correct | 32 ms | 4716 KB | Output is correct |
98 | Correct | 129 ms | 18284 KB | Output is correct |
99 | Correct | 137 ms | 16236 KB | Output is correct |
100 | Correct | 122 ms | 16336 KB | Output is correct |
101 | Correct | 131 ms | 18176 KB | Output is correct |
102 | Correct | 134 ms | 18156 KB | Output is correct |
103 | Correct | 123 ms | 18256 KB | Output is correct |
104 | Correct | 116 ms | 18156 KB | Output is correct |
105 | Correct | 130 ms | 18256 KB | Output is correct |