# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
433580 | 2021-06-20T07:49:11 Z | sean617 | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 302 ms | 23176 KB |
#include "supertrees.h" #include <vector> #include <cstring> #define N 1005 using namespace std; int n, cnt, bu[N], bu2[N], gut[N]; bool v[N], co[N][N], icy[N]; vector<int> gu[N], cy[N], cy2, ans, ch[N]; vector<std::vector<int> > answer; int f(int p) { if (bu[p] == p) return p; else return bu[p] = f(bu[p]); } int f2(int p) { if (bu2[p] == p) return p; else return bu2[p] = f2(bu2[p]); } void f_co(int p, int q) { co[p][q] = co[q][p] = 1; } int construct(std::vector<std::vector<int> > p) { int i, j, k, t, t1, t2, la, tcnt; n = p.size(); for (i = 0; i < n; i++) {bu[i] = i; bu2[i] = i;} for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (p[i][j]== 0) continue; if (p[i][j] == 3) return 0; t1 = f(i); t2 = f(j); if (t1 != t2) bu[t1] = t2; } } memset(gut, -1, sizeof(gut)); for (i = 0; i < n; i++) f(i); for (i = 0; i < n; i++) { tcnt = 0; for (j = 0; j < n; j++) { if (i == j) continue; if (bu[i] != bu[j]) continue; if (p[i][j] == 0) return 0; if (p[i][j] == 1) { t1 = f2(i); t2 = f2(j); if (t1 != t2) bu2[t1] = t2; tcnt++; } } if (tcnt == 0) { icy[i] = 1; cy[bu[i]].push_back(i); } } for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (bu2[i] != bu2[j]) continue; if (p[i][j] != 1) return 0; } } for (i = 0; i < n; i++) { if (cy[i].empty()) continue; for (j = 0; j < cy[i].size(); j++) { for (k = j + 1; k < cy[i].size(); k++) { t1 = cy[i][j]; t2 = cy[i][k]; if (p[t1][t2] != 2) return 0; } } } for (i = 0; i < n; i++) { if (icy[i]) continue; for (j = i + 1; j < n; j++) { if (bu[i] != bu[j]) continue; if (bu2[i] == bu2[j] && p[i][j] != 1 || bu2[i] != bu2[j] && p[i][j] != 2) return 0; } if (gut[bu2[i]] == -1) { cy[bu[i]].push_back(i); } else { f_co(gut[bu2[i]], i); } gut[bu2[i]] = i; } for (i = 0; i < n; i++) { if (cy[i].empty() || cy[i].size() == 1) continue; if (cy[i].size() == 2) return 0; int cysz = cy[i].size(); for (j = 0; j < cysz; j++) { t1 = cy[i][j]; t2 = cy[i][(j + 1) % cysz]; f_co(t1, t2); } } for (i = 0; i < n; i++) { ans.clear(); for (j =0; j < n; j++) { ans.push_back(co[i][j]); } answer.push_back(ans); } build(answer); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 10 ms | 1356 KB | Output is correct |
7 | Correct | 302 ms | 23096 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 10 ms | 1356 KB | Output is correct |
7 | Correct | 302 ms | 23096 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 15 ms | 1228 KB | Output is correct |
13 | Correct | 261 ms | 22148 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 7 ms | 588 KB | Output is correct |
17 | Correct | 108 ms | 8128 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 67 ms | 6332 KB | Output is correct |
21 | Correct | 267 ms | 23108 KB | Output is correct |
22 | Correct | 279 ms | 23100 KB | Output is correct |
23 | Correct | 267 ms | 23128 KB | Output is correct |
24 | Correct | 241 ms | 22340 KB | Output is correct |
25 | Correct | 107 ms | 8132 KB | Output is correct |
26 | Correct | 105 ms | 8124 KB | Output is correct |
27 | Correct | 254 ms | 23100 KB | Output is correct |
28 | Correct | 243 ms | 22240 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 12 ms | 1160 KB | Output is correct |
9 | Correct | 241 ms | 22080 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 11 ms | 1456 KB | Output is correct |
13 | Correct | 238 ms | 23100 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 5 ms | 588 KB | Output is correct |
17 | Correct | 111 ms | 8128 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 0 ms | 332 KB | Output is correct |
21 | Correct | 61 ms | 6332 KB | Output is correct |
22 | Correct | 243 ms | 23028 KB | Output is correct |
23 | Correct | 255 ms | 23100 KB | Output is correct |
24 | Correct | 241 ms | 23116 KB | Output is correct |
25 | Correct | 109 ms | 8256 KB | Output is correct |
26 | Correct | 100 ms | 8120 KB | Output is correct |
27 | Correct | 240 ms | 23116 KB | Output is correct |
28 | Correct | 244 ms | 23100 KB | Output is correct |
29 | Correct | 101 ms | 8260 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 61 ms | 6312 KB | Output is correct |
5 | Correct | 257 ms | 23040 KB | Output is correct |
6 | Correct | 245 ms | 23108 KB | Output is correct |
7 | Correct | 282 ms | 23104 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 59 ms | 6264 KB | Output is correct |
10 | Correct | 301 ms | 23176 KB | Output is correct |
11 | Correct | 239 ms | 23100 KB | Output is correct |
12 | Correct | 250 ms | 23108 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 62 ms | 6340 KB | Output is correct |
17 | Correct | 297 ms | 23116 KB | Output is correct |
18 | Correct | 245 ms | 23116 KB | Output is correct |
19 | Correct | 239 ms | 23092 KB | Output is correct |
20 | Correct | 238 ms | 22340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 10 ms | 1356 KB | Output is correct |
7 | Correct | 302 ms | 23096 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 15 ms | 1228 KB | Output is correct |
13 | Correct | 261 ms | 22148 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 7 ms | 588 KB | Output is correct |
17 | Correct | 108 ms | 8128 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 67 ms | 6332 KB | Output is correct |
21 | Correct | 267 ms | 23108 KB | Output is correct |
22 | Correct | 279 ms | 23100 KB | Output is correct |
23 | Correct | 267 ms | 23128 KB | Output is correct |
24 | Correct | 241 ms | 22340 KB | Output is correct |
25 | Correct | 107 ms | 8132 KB | Output is correct |
26 | Correct | 105 ms | 8124 KB | Output is correct |
27 | Correct | 254 ms | 23100 KB | Output is correct |
28 | Correct | 243 ms | 22240 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 1 ms | 332 KB | Output is correct |
32 | Correct | 0 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 332 KB | Output is correct |
34 | Correct | 1 ms | 332 KB | Output is correct |
35 | Correct | 1 ms | 332 KB | Output is correct |
36 | Correct | 12 ms | 1160 KB | Output is correct |
37 | Correct | 241 ms | 22080 KB | Output is correct |
38 | Correct | 1 ms | 332 KB | Output is correct |
39 | Correct | 1 ms | 332 KB | Output is correct |
40 | Correct | 11 ms | 1456 KB | Output is correct |
41 | Correct | 238 ms | 23100 KB | Output is correct |
42 | Correct | 1 ms | 332 KB | Output is correct |
43 | Correct | 0 ms | 332 KB | Output is correct |
44 | Correct | 5 ms | 588 KB | Output is correct |
45 | Correct | 111 ms | 8128 KB | Output is correct |
46 | Correct | 1 ms | 332 KB | Output is correct |
47 | Correct | 1 ms | 332 KB | Output is correct |
48 | Correct | 0 ms | 332 KB | Output is correct |
49 | Correct | 61 ms | 6332 KB | Output is correct |
50 | Correct | 243 ms | 23028 KB | Output is correct |
51 | Correct | 255 ms | 23100 KB | Output is correct |
52 | Correct | 241 ms | 23116 KB | Output is correct |
53 | Correct | 109 ms | 8256 KB | Output is correct |
54 | Correct | 100 ms | 8120 KB | Output is correct |
55 | Correct | 240 ms | 23116 KB | Output is correct |
56 | Correct | 244 ms | 23100 KB | Output is correct |
57 | Correct | 101 ms | 8260 KB | Output is correct |
58 | Correct | 0 ms | 332 KB | Output is correct |
59 | Correct | 1 ms | 332 KB | Output is correct |
60 | Correct | 5 ms | 688 KB | Output is correct |
61 | Correct | 107 ms | 8124 KB | Output is correct |
62 | Correct | 1 ms | 332 KB | Output is correct |
63 | Correct | 1 ms | 332 KB | Output is correct |
64 | Correct | 1 ms | 332 KB | Output is correct |
65 | Correct | 61 ms | 6216 KB | Output is correct |
66 | Correct | 101 ms | 8128 KB | Output is correct |
67 | Correct | 102 ms | 8140 KB | Output is correct |
68 | Correct | 101 ms | 8144 KB | Output is correct |
69 | Correct | 102 ms | 8388 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 10 ms | 1356 KB | Output is correct |
7 | Correct | 302 ms | 23096 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 15 ms | 1228 KB | Output is correct |
13 | Correct | 261 ms | 22148 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 7 ms | 588 KB | Output is correct |
17 | Correct | 108 ms | 8128 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 67 ms | 6332 KB | Output is correct |
21 | Correct | 267 ms | 23108 KB | Output is correct |
22 | Correct | 279 ms | 23100 KB | Output is correct |
23 | Correct | 267 ms | 23128 KB | Output is correct |
24 | Correct | 241 ms | 22340 KB | Output is correct |
25 | Correct | 107 ms | 8132 KB | Output is correct |
26 | Correct | 105 ms | 8124 KB | Output is correct |
27 | Correct | 254 ms | 23100 KB | Output is correct |
28 | Correct | 243 ms | 22240 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 1 ms | 332 KB | Output is correct |
32 | Correct | 0 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 332 KB | Output is correct |
34 | Correct | 1 ms | 332 KB | Output is correct |
35 | Correct | 1 ms | 332 KB | Output is correct |
36 | Correct | 12 ms | 1160 KB | Output is correct |
37 | Correct | 241 ms | 22080 KB | Output is correct |
38 | Correct | 1 ms | 332 KB | Output is correct |
39 | Correct | 1 ms | 332 KB | Output is correct |
40 | Correct | 11 ms | 1456 KB | Output is correct |
41 | Correct | 238 ms | 23100 KB | Output is correct |
42 | Correct | 1 ms | 332 KB | Output is correct |
43 | Correct | 0 ms | 332 KB | Output is correct |
44 | Correct | 5 ms | 588 KB | Output is correct |
45 | Correct | 111 ms | 8128 KB | Output is correct |
46 | Correct | 1 ms | 332 KB | Output is correct |
47 | Correct | 1 ms | 332 KB | Output is correct |
48 | Correct | 0 ms | 332 KB | Output is correct |
49 | Correct | 61 ms | 6332 KB | Output is correct |
50 | Correct | 243 ms | 23028 KB | Output is correct |
51 | Correct | 255 ms | 23100 KB | Output is correct |
52 | Correct | 241 ms | 23116 KB | Output is correct |
53 | Correct | 109 ms | 8256 KB | Output is correct |
54 | Correct | 100 ms | 8120 KB | Output is correct |
55 | Correct | 240 ms | 23116 KB | Output is correct |
56 | Correct | 244 ms | 23100 KB | Output is correct |
57 | Correct | 101 ms | 8260 KB | Output is correct |
58 | Correct | 0 ms | 332 KB | Output is correct |
59 | Correct | 1 ms | 332 KB | Output is correct |
60 | Correct | 1 ms | 332 KB | Output is correct |
61 | Correct | 61 ms | 6312 KB | Output is correct |
62 | Correct | 257 ms | 23040 KB | Output is correct |
63 | Correct | 245 ms | 23108 KB | Output is correct |
64 | Correct | 282 ms | 23104 KB | Output is correct |
65 | Correct | 1 ms | 332 KB | Output is correct |
66 | Correct | 59 ms | 6264 KB | Output is correct |
67 | Correct | 301 ms | 23176 KB | Output is correct |
68 | Correct | 239 ms | 23100 KB | Output is correct |
69 | Correct | 250 ms | 23108 KB | Output is correct |
70 | Correct | 0 ms | 332 KB | Output is correct |
71 | Correct | 1 ms | 332 KB | Output is correct |
72 | Correct | 1 ms | 332 KB | Output is correct |
73 | Correct | 62 ms | 6340 KB | Output is correct |
74 | Correct | 297 ms | 23116 KB | Output is correct |
75 | Correct | 245 ms | 23116 KB | Output is correct |
76 | Correct | 239 ms | 23092 KB | Output is correct |
77 | Correct | 238 ms | 22340 KB | Output is correct |
78 | Correct | 0 ms | 332 KB | Output is correct |
79 | Correct | 1 ms | 332 KB | Output is correct |
80 | Correct | 5 ms | 688 KB | Output is correct |
81 | Correct | 107 ms | 8124 KB | Output is correct |
82 | Correct | 1 ms | 332 KB | Output is correct |
83 | Correct | 1 ms | 332 KB | Output is correct |
84 | Correct | 1 ms | 332 KB | Output is correct |
85 | Correct | 61 ms | 6216 KB | Output is correct |
86 | Correct | 101 ms | 8128 KB | Output is correct |
87 | Correct | 102 ms | 8140 KB | Output is correct |
88 | Correct | 101 ms | 8144 KB | Output is correct |
89 | Correct | 102 ms | 8388 KB | Output is correct |
90 | Correct | 0 ms | 332 KB | Output is correct |
91 | Correct | 1 ms | 332 KB | Output is correct |
92 | Correct | 7 ms | 644 KB | Output is correct |
93 | Correct | 109 ms | 8128 KB | Output is correct |
94 | Correct | 1 ms | 332 KB | Output is correct |
95 | Correct | 0 ms | 332 KB | Output is correct |
96 | Correct | 0 ms | 332 KB | Output is correct |
97 | Correct | 32 ms | 2240 KB | Output is correct |
98 | Correct | 106 ms | 8136 KB | Output is correct |
99 | Correct | 99 ms | 8256 KB | Output is correct |
100 | Correct | 102 ms | 8140 KB | Output is correct |
101 | Correct | 98 ms | 8124 KB | Output is correct |
102 | Correct | 97 ms | 8136 KB | Output is correct |
103 | Correct | 97 ms | 8128 KB | Output is correct |
104 | Correct | 103 ms | 8136 KB | Output is correct |
105 | Correct | 102 ms | 8128 KB | Output is correct |