# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
405073 | 2021-05-15T16:40:25 Z | ly20 | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 279 ms | 32120 KB |
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1123; int comp[MAXN]; vector <int> grafo[MAXN]; int marc[MAXN]; int cmp; //vector <int> grafo2[MAXN]; void dfs(int v) { marc[v] = 1; comp[v] = cmp; for(int i = 0; i < grafo[v].size(); i++) { int viz = grafo[v][i]; if(marc[viz] == 1) continue; dfs(viz); } } int resp[MAXN][MAXN]; int cic[MAXN][MAXN]; int rep[MAXN]; int cm2[MAXN], cmp2; int marc2[MAXN]; vector <int> ln[MAXN]; vector <vector <int> > answer; //vector <int> temp; void dfs2(int v) { marc2[v] = 1; cm2[v] = cmp2; for(int i = 0; i < cmp; i++) { if(marc2[i] == 1) continue; if(cic[v][i] == 1) dfs2(i); } } int construct(vector<vector<int>> p) { int n = p.size(); vector<vector<int>> answer; for(int i = 0; i < n; i++) { comp[i] = i; } for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(p[i][j] == 1) { grafo[i].push_back(j); } } } for(int i = 0; i < n; i++) { if(marc[i] == 0) { dfs(i); cmp++; } } for(int i = 0; i < cmp; i++) { for(int j = 0; j < n; j++) if(comp[j] == i) ln[i].push_back(j); int m = ln[i].size(); for(int j = 0; j < m; j++) { int cur = ln[i][j]; for(int k = j + 1; k < m; k++) { int tst = ln[i][k]; if(p[cur][tst] != 1) { return 0; } } } for(int j = 0; j < m - 1; j++) { int pr = j + 1; resp[ln[i][j]][ln[i][pr]] = 1; resp[ln[i][pr]][ln[i][j]] = 1; } rep[i] = ln[i][0]; } for(int i = 0; i < cmp; i++) { for(int j = i + 1; j < cmp; j++) { int bs = p[rep[i]][rep[j]]; for(int k = 0; k < ln[i].size(); k++) { for(int l = 0; l < ln[j].size(); l++) { if(p[ln[i][k]][ln[j][l]] != bs) bs = -1; } } if(bs == 2) { cic[i][j] = 1; cic[j][i] = 1; } else if(bs == -1 || bs == 1) return 0; } } for(int i = 0; i < cmp; i++) { if(marc2[i] == 0) { dfs2(i); cmp2++; } } for(int i = 0; i < cmp2; i++) { vector <int> temp; for(int j = 0; j < cmp; j++) if(cm2[j] == i) temp.push_back(j); int m = temp.size(); for(int j = 0; j < m; j++) { for(int k = j + 1; k < m; k++) { if(cic[temp[j]][temp[k]] == 0) return 0; } } if(temp.size() == 1) continue; for(int j = 0; j < m; j++) { int pr = (j + 1) % m; resp[rep[temp[pr]]][rep[temp[j]]] = 1; resp[rep[temp[j]]][rep[temp[pr]]] = 1; } if(temp.size() == 2) return 0; } for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(i == j) continue; if(cm2[comp[i]] != cm2[comp[j]]) { if(p[i][j] != 0) return 0; } else { if(comp[i] == comp[j]) { if(p[i][j] != 1) return 0; } else { if(p[i][j] != 2) return 0; } } } } for (int i = 0; i < n; i++) { vector<int> row; for(int j = 0; j < n; j++) { row.push_back(resp[i][j]); } answer.push_back(row); } build(answer); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | 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 | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 11 ms | 2252 KB | Output is correct |
7 | Correct | 242 ms | 30276 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 | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 11 ms | 2252 KB | Output is correct |
7 | Correct | 242 ms | 30276 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 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 | 1288 KB | Output is correct |
13 | Correct | 244 ms | 22168 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 5 ms | 716 KB | Output is correct |
17 | Correct | 111 ms | 10692 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 60 ms | 7756 KB | Output is correct |
21 | Correct | 245 ms | 26744 KB | Output is correct |
22 | Correct | 239 ms | 25916 KB | Output is correct |
23 | Correct | 244 ms | 28160 KB | Output is correct |
24 | Correct | 244 ms | 22468 KB | Output is correct |
25 | Correct | 97 ms | 10824 KB | Output is correct |
26 | Correct | 95 ms | 8504 KB | Output is correct |
27 | Correct | 248 ms | 29256 KB | Output is correct |
28 | Correct | 239 ms | 22372 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 | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 352 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 356 KB | Output is correct |
8 | Correct | 11 ms | 1368 KB | Output is correct |
9 | Correct | 251 ms | 23336 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 | 3020 KB | Output is correct |
13 | Correct | 242 ms | 31784 KB | Output is correct |
14 | Correct | 1 ms | 352 KB | Output is correct |
15 | Correct | 1 ms | 356 KB | Output is correct |
16 | Correct | 6 ms | 1640 KB | Output is correct |
17 | Correct | 114 ms | 14056 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 63 ms | 10164 KB | Output is correct |
22 | Correct | 253 ms | 31924 KB | Output is correct |
23 | Correct | 242 ms | 32068 KB | Output is correct |
24 | Correct | 255 ms | 31840 KB | Output is correct |
25 | Correct | 107 ms | 10180 KB | Output is correct |
26 | Correct | 107 ms | 14720 KB | Output is correct |
27 | Correct | 245 ms | 32120 KB | Output is correct |
28 | Correct | 263 ms | 32008 KB | Output is correct |
29 | Correct | 105 ms | 10180 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 | 62 ms | 7828 KB | Output is correct |
5 | Correct | 240 ms | 26676 KB | Output is correct |
6 | Correct | 234 ms | 25864 KB | Output is correct |
7 | Correct | 262 ms | 28096 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 65 ms | 9784 KB | Output is correct |
10 | Correct | 245 ms | 30656 KB | Output is correct |
11 | Correct | 279 ms | 30784 KB | Output is correct |
12 | Correct | 261 ms | 30528 KB | Output is correct |
13 | Correct | 1 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 | 61 ms | 9528 KB | Output is correct |
17 | Correct | 242 ms | 30652 KB | Output is correct |
18 | Correct | 242 ms | 28620 KB | Output is correct |
19 | Correct | 238 ms | 28996 KB | Output is correct |
20 | Correct | 240 ms | 22604 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 | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 11 ms | 2252 KB | Output is correct |
7 | Correct | 242 ms | 30276 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 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 | 1288 KB | Output is correct |
13 | Correct | 244 ms | 22168 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 5 ms | 716 KB | Output is correct |
17 | Correct | 111 ms | 10692 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 60 ms | 7756 KB | Output is correct |
21 | Correct | 245 ms | 26744 KB | Output is correct |
22 | Correct | 239 ms | 25916 KB | Output is correct |
23 | Correct | 244 ms | 28160 KB | Output is correct |
24 | Correct | 244 ms | 22468 KB | Output is correct |
25 | Correct | 97 ms | 10824 KB | Output is correct |
26 | Correct | 95 ms | 8504 KB | Output is correct |
27 | Correct | 248 ms | 29256 KB | Output is correct |
28 | Correct | 239 ms | 22372 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 | 1 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 352 KB | Output is correct |
34 | Correct | 1 ms | 332 KB | Output is correct |
35 | Correct | 1 ms | 356 KB | Output is correct |
36 | Correct | 11 ms | 1368 KB | Output is correct |
37 | Correct | 251 ms | 23336 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 | 3020 KB | Output is correct |
41 | Correct | 242 ms | 31784 KB | Output is correct |
42 | Correct | 1 ms | 352 KB | Output is correct |
43 | Correct | 1 ms | 356 KB | Output is correct |
44 | Correct | 6 ms | 1640 KB | Output is correct |
45 | Correct | 114 ms | 14056 KB | Output is correct |
46 | Correct | 1 ms | 332 KB | Output is correct |
47 | Correct | 1 ms | 332 KB | Output is correct |
48 | Correct | 1 ms | 332 KB | Output is correct |
49 | Correct | 63 ms | 10164 KB | Output is correct |
50 | Correct | 253 ms | 31924 KB | Output is correct |
51 | Correct | 242 ms | 32068 KB | Output is correct |
52 | Correct | 255 ms | 31840 KB | Output is correct |
53 | Correct | 107 ms | 10180 KB | Output is correct |
54 | Correct | 107 ms | 14720 KB | Output is correct |
55 | Correct | 245 ms | 32120 KB | Output is correct |
56 | Correct | 263 ms | 32008 KB | Output is correct |
57 | Correct | 105 ms | 10180 KB | Output is correct |
58 | Correct | 1 ms | 332 KB | Output is correct |
59 | Correct | 1 ms | 360 KB | Output is correct |
60 | Correct | 6 ms | 852 KB | Output is correct |
61 | Correct | 110 ms | 12208 KB | Output is correct |
62 | Correct | 1 ms | 360 KB | Output is correct |
63 | Correct | 1 ms | 352 KB | Output is correct |
64 | Correct | 1 ms | 352 KB | Output is correct |
65 | Correct | 63 ms | 9852 KB | Output is correct |
66 | Correct | 99 ms | 9984 KB | Output is correct |
67 | Correct | 98 ms | 10164 KB | Output is correct |
68 | Correct | 98 ms | 12136 KB | Output is correct |
69 | Correct | 101 ms | 9928 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 | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 11 ms | 2252 KB | Output is correct |
7 | Correct | 242 ms | 30276 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 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 | 1288 KB | Output is correct |
13 | Correct | 244 ms | 22168 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 5 ms | 716 KB | Output is correct |
17 | Correct | 111 ms | 10692 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 60 ms | 7756 KB | Output is correct |
21 | Correct | 245 ms | 26744 KB | Output is correct |
22 | Correct | 239 ms | 25916 KB | Output is correct |
23 | Correct | 244 ms | 28160 KB | Output is correct |
24 | Correct | 244 ms | 22468 KB | Output is correct |
25 | Correct | 97 ms | 10824 KB | Output is correct |
26 | Correct | 95 ms | 8504 KB | Output is correct |
27 | Correct | 248 ms | 29256 KB | Output is correct |
28 | Correct | 239 ms | 22372 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 | 1 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 352 KB | Output is correct |
34 | Correct | 1 ms | 332 KB | Output is correct |
35 | Correct | 1 ms | 356 KB | Output is correct |
36 | Correct | 11 ms | 1368 KB | Output is correct |
37 | Correct | 251 ms | 23336 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 | 3020 KB | Output is correct |
41 | Correct | 242 ms | 31784 KB | Output is correct |
42 | Correct | 1 ms | 352 KB | Output is correct |
43 | Correct | 1 ms | 356 KB | Output is correct |
44 | Correct | 6 ms | 1640 KB | Output is correct |
45 | Correct | 114 ms | 14056 KB | Output is correct |
46 | Correct | 1 ms | 332 KB | Output is correct |
47 | Correct | 1 ms | 332 KB | Output is correct |
48 | Correct | 1 ms | 332 KB | Output is correct |
49 | Correct | 63 ms | 10164 KB | Output is correct |
50 | Correct | 253 ms | 31924 KB | Output is correct |
51 | Correct | 242 ms | 32068 KB | Output is correct |
52 | Correct | 255 ms | 31840 KB | Output is correct |
53 | Correct | 107 ms | 10180 KB | Output is correct |
54 | Correct | 107 ms | 14720 KB | Output is correct |
55 | Correct | 245 ms | 32120 KB | Output is correct |
56 | Correct | 263 ms | 32008 KB | Output is correct |
57 | Correct | 105 ms | 10180 KB | Output is correct |
58 | Correct | 1 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 | 62 ms | 7828 KB | Output is correct |
62 | Correct | 240 ms | 26676 KB | Output is correct |
63 | Correct | 234 ms | 25864 KB | Output is correct |
64 | Correct | 262 ms | 28096 KB | Output is correct |
65 | Correct | 1 ms | 332 KB | Output is correct |
66 | Correct | 65 ms | 9784 KB | Output is correct |
67 | Correct | 245 ms | 30656 KB | Output is correct |
68 | Correct | 279 ms | 30784 KB | Output is correct |
69 | Correct | 261 ms | 30528 KB | Output is correct |
70 | Correct | 1 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 | 61 ms | 9528 KB | Output is correct |
74 | Correct | 242 ms | 30652 KB | Output is correct |
75 | Correct | 242 ms | 28620 KB | Output is correct |
76 | Correct | 238 ms | 28996 KB | Output is correct |
77 | Correct | 240 ms | 22604 KB | Output is correct |
78 | Correct | 1 ms | 332 KB | Output is correct |
79 | Correct | 1 ms | 360 KB | Output is correct |
80 | Correct | 6 ms | 852 KB | Output is correct |
81 | Correct | 110 ms | 12208 KB | Output is correct |
82 | Correct | 1 ms | 360 KB | Output is correct |
83 | Correct | 1 ms | 352 KB | Output is correct |
84 | Correct | 1 ms | 352 KB | Output is correct |
85 | Correct | 63 ms | 9852 KB | Output is correct |
86 | Correct | 99 ms | 9984 KB | Output is correct |
87 | Correct | 98 ms | 10164 KB | Output is correct |
88 | Correct | 98 ms | 12136 KB | Output is correct |
89 | Correct | 101 ms | 9928 KB | Output is correct |
90 | Correct | 1 ms | 356 KB | Output is correct |
91 | Correct | 1 ms | 332 KB | Output is correct |
92 | Correct | 5 ms | 716 KB | Output is correct |
93 | Correct | 108 ms | 10920 KB | Output is correct |
94 | Correct | 1 ms | 332 KB | Output is correct |
95 | Correct | 1 ms | 332 KB | Output is correct |
96 | Correct | 1 ms | 332 KB | Output is correct |
97 | Correct | 27 ms | 6372 KB | Output is correct |
98 | Correct | 108 ms | 17672 KB | Output is correct |
99 | Correct | 100 ms | 14144 KB | Output is correct |
100 | Correct | 99 ms | 12504 KB | Output is correct |
101 | Correct | 104 ms | 9608 KB | Output is correct |
102 | Correct | 110 ms | 9264 KB | Output is correct |
103 | Correct | 107 ms | 13596 KB | Output is correct |
104 | Correct | 107 ms | 11620 KB | Output is correct |
105 | Correct | 117 ms | 9264 KB | Output is correct |