# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1119139 | 2024-11-26T16:20:42 Z | alexdd | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 210 ms | 28040 KB |
#include<bits/stdc++.h> #include "supertrees.h" using namespace std; int n; bool visited[1005]; vector<int> comp; vector<vector<int>> p; void dfs(int nod) { comp.push_back(nod); visited[nod]=1; for(int i=0;i<n;i++) if(!visited[i] && p[nod][i]>0) dfs(i); } vector<int> aux; void dfs2(int nod) { visited[nod]=1; aux.push_back(nod); for(int i=0;i<n;i++) if(!visited[i] && p[nod][i]==1) dfs2(i); } int construct(vector<vector<int>> copp) { p = copp; n = p.size(); vector<vector<int>> b(n, vector<int>(n)); for(int i=0;i<n;i++) { if(!visited[i]) { comp.clear(); dfs(i); for(int x:comp) visited[x]=0; vector<int> roots; vector<vector<int>> cv; for(int x:comp) { if(!visited[x]) { roots.push_back(x); aux.clear(); dfs2(x); cv.push_back(aux); for(int u:aux) for(int v:aux) if(p[u][v]!=1) return 0; for(auto y:aux) if(y!=x) b[x][y]=b[y][x]=1; } } for(int u=0;u<cv.size();u++) { for(int v=u+1;v<cv.size();v++) { for(int x:cv[u]) for(int y:cv[v]) if(p[x][y] != 2) return 0; } } if((int)roots.size() == 2) return 0; if((int)roots.size() > 1) { for(int i=0;i+1<roots.size();i++) b[roots[i]][roots[i+1]] = b[roots[i+1]][roots[i]] = 1; b[roots[0]][roots.back()] = b[roots.back()][roots[0]] = 1; } } } build(b); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 504 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 0 ms | 336 KB | Output is correct |
6 | Correct | 5 ms | 1360 KB | Output is correct |
7 | Correct | 172 ms | 26184 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 504 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 0 ms | 336 KB | Output is correct |
6 | Correct | 5 ms | 1360 KB | Output is correct |
7 | Correct | 172 ms | 26184 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 7 ms | 1380 KB | Output is correct |
13 | Correct | 201 ms | 25928 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 6 ms | 1104 KB | Output is correct |
17 | Correct | 81 ms | 18060 KB | Output is correct |
18 | Correct | 1 ms | 336 KB | Output is correct |
19 | Correct | 1 ms | 336 KB | Output is correct |
20 | Correct | 38 ms | 7268 KB | Output is correct |
21 | Correct | 170 ms | 28040 KB | Output is correct |
22 | Correct | 183 ms | 28036 KB | Output is correct |
23 | Correct | 182 ms | 28032 KB | Output is correct |
24 | Correct | 189 ms | 27920 KB | Output is correct |
25 | Correct | 64 ms | 17992 KB | Output is correct |
26 | Correct | 61 ms | 17928 KB | Output is correct |
27 | Correct | 187 ms | 27972 KB | Output is correct |
28 | Correct | 210 ms | 28008 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 9 ms | 1360 KB | Output is correct |
9 | Correct | 193 ms | 26140 KB | Output is correct |
10 | Correct | 2 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 8 ms | 1360 KB | Output is correct |
13 | Correct | 174 ms | 26140 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 5 ms | 1116 KB | Output is correct |
17 | Correct | 78 ms | 16156 KB | Output is correct |
18 | Correct | 2 ms | 336 KB | Output is correct |
19 | Correct | 1 ms | 336 KB | Output is correct |
20 | Correct | 1 ms | 336 KB | Output is correct |
21 | Correct | 57 ms | 6784 KB | Output is correct |
22 | Correct | 191 ms | 25928 KB | Output is correct |
23 | Correct | 192 ms | 25900 KB | Output is correct |
24 | Correct | 170 ms | 26132 KB | Output is correct |
25 | Correct | 56 ms | 16184 KB | Output is correct |
26 | Correct | 82 ms | 16144 KB | Output is correct |
27 | Correct | 181 ms | 25928 KB | Output is correct |
28 | Correct | 169 ms | 26140 KB | Output is correct |
29 | Correct | 129 ms | 16148 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 504 KB | Output is correct |
4 | Correct | 47 ms | 6728 KB | Output is correct |
5 | Correct | 193 ms | 26140 KB | Output is correct |
6 | Correct | 166 ms | 26136 KB | Output is correct |
7 | Correct | 169 ms | 26184 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 39 ms | 6792 KB | Output is correct |
10 | Correct | 174 ms | 26084 KB | Output is correct |
11 | Correct | 181 ms | 25928 KB | Output is correct |
12 | Correct | 150 ms | 26136 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 42 ms | 6768 KB | Output is correct |
17 | Correct | 139 ms | 26140 KB | Output is correct |
18 | Correct | 158 ms | 26140 KB | Output is correct |
19 | Correct | 174 ms | 26140 KB | Output is correct |
20 | Correct | 166 ms | 26136 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 504 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 0 ms | 336 KB | Output is correct |
6 | Correct | 5 ms | 1360 KB | Output is correct |
7 | Correct | 172 ms | 26184 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 7 ms | 1380 KB | Output is correct |
13 | Correct | 201 ms | 25928 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 6 ms | 1104 KB | Output is correct |
17 | Correct | 81 ms | 18060 KB | Output is correct |
18 | Correct | 1 ms | 336 KB | Output is correct |
19 | Correct | 1 ms | 336 KB | Output is correct |
20 | Correct | 38 ms | 7268 KB | Output is correct |
21 | Correct | 170 ms | 28040 KB | Output is correct |
22 | Correct | 183 ms | 28036 KB | Output is correct |
23 | Correct | 182 ms | 28032 KB | Output is correct |
24 | Correct | 189 ms | 27920 KB | Output is correct |
25 | Correct | 64 ms | 17992 KB | Output is correct |
26 | Correct | 61 ms | 17928 KB | Output is correct |
27 | Correct | 187 ms | 27972 KB | Output is correct |
28 | Correct | 210 ms | 28008 KB | Output is correct |
29 | Correct | 1 ms | 336 KB | Output is correct |
30 | Correct | 1 ms | 336 KB | Output is correct |
31 | Correct | 1 ms | 336 KB | Output is correct |
32 | Correct | 1 ms | 336 KB | Output is correct |
33 | Correct | 1 ms | 336 KB | Output is correct |
34 | Correct | 1 ms | 336 KB | Output is correct |
35 | Correct | 1 ms | 336 KB | Output is correct |
36 | Correct | 9 ms | 1360 KB | Output is correct |
37 | Correct | 193 ms | 26140 KB | Output is correct |
38 | Correct | 2 ms | 336 KB | Output is correct |
39 | Correct | 1 ms | 336 KB | Output is correct |
40 | Correct | 8 ms | 1360 KB | Output is correct |
41 | Correct | 174 ms | 26140 KB | Output is correct |
42 | Correct | 1 ms | 336 KB | Output is correct |
43 | Correct | 1 ms | 336 KB | Output is correct |
44 | Correct | 5 ms | 1116 KB | Output is correct |
45 | Correct | 78 ms | 16156 KB | Output is correct |
46 | Correct | 2 ms | 336 KB | Output is correct |
47 | Correct | 1 ms | 336 KB | Output is correct |
48 | Correct | 1 ms | 336 KB | Output is correct |
49 | Correct | 57 ms | 6784 KB | Output is correct |
50 | Correct | 191 ms | 25928 KB | Output is correct |
51 | Correct | 192 ms | 25900 KB | Output is correct |
52 | Correct | 170 ms | 26132 KB | Output is correct |
53 | Correct | 56 ms | 16184 KB | Output is correct |
54 | Correct | 82 ms | 16144 KB | Output is correct |
55 | Correct | 181 ms | 25928 KB | Output is correct |
56 | Correct | 169 ms | 26140 KB | Output is correct |
57 | Correct | 129 ms | 16148 KB | Output is correct |
58 | Correct | 1 ms | 772 KB | Output is correct |
59 | Correct | 1 ms | 336 KB | Output is correct |
60 | Correct | 6 ms | 1104 KB | Output is correct |
61 | Correct | 82 ms | 18108 KB | Output is correct |
62 | Correct | 1 ms | 592 KB | Output is correct |
63 | Correct | 1 ms | 336 KB | Output is correct |
64 | Correct | 1 ms | 336 KB | Output is correct |
65 | Correct | 48 ms | 7256 KB | Output is correct |
66 | Correct | 106 ms | 18104 KB | Output is correct |
67 | Correct | 86 ms | 17992 KB | Output is correct |
68 | Correct | 78 ms | 18188 KB | Output is correct |
69 | Correct | 60 ms | 17988 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 504 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 0 ms | 336 KB | Output is correct |
6 | Correct | 5 ms | 1360 KB | Output is correct |
7 | Correct | 172 ms | 26184 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 7 ms | 1380 KB | Output is correct |
13 | Correct | 201 ms | 25928 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 6 ms | 1104 KB | Output is correct |
17 | Correct | 81 ms | 18060 KB | Output is correct |
18 | Correct | 1 ms | 336 KB | Output is correct |
19 | Correct | 1 ms | 336 KB | Output is correct |
20 | Correct | 38 ms | 7268 KB | Output is correct |
21 | Correct | 170 ms | 28040 KB | Output is correct |
22 | Correct | 183 ms | 28036 KB | Output is correct |
23 | Correct | 182 ms | 28032 KB | Output is correct |
24 | Correct | 189 ms | 27920 KB | Output is correct |
25 | Correct | 64 ms | 17992 KB | Output is correct |
26 | Correct | 61 ms | 17928 KB | Output is correct |
27 | Correct | 187 ms | 27972 KB | Output is correct |
28 | Correct | 210 ms | 28008 KB | Output is correct |
29 | Correct | 1 ms | 336 KB | Output is correct |
30 | Correct | 1 ms | 336 KB | Output is correct |
31 | Correct | 1 ms | 336 KB | Output is correct |
32 | Correct | 1 ms | 336 KB | Output is correct |
33 | Correct | 1 ms | 336 KB | Output is correct |
34 | Correct | 1 ms | 336 KB | Output is correct |
35 | Correct | 1 ms | 336 KB | Output is correct |
36 | Correct | 9 ms | 1360 KB | Output is correct |
37 | Correct | 193 ms | 26140 KB | Output is correct |
38 | Correct | 2 ms | 336 KB | Output is correct |
39 | Correct | 1 ms | 336 KB | Output is correct |
40 | Correct | 8 ms | 1360 KB | Output is correct |
41 | Correct | 174 ms | 26140 KB | Output is correct |
42 | Correct | 1 ms | 336 KB | Output is correct |
43 | Correct | 1 ms | 336 KB | Output is correct |
44 | Correct | 5 ms | 1116 KB | Output is correct |
45 | Correct | 78 ms | 16156 KB | Output is correct |
46 | Correct | 2 ms | 336 KB | Output is correct |
47 | Correct | 1 ms | 336 KB | Output is correct |
48 | Correct | 1 ms | 336 KB | Output is correct |
49 | Correct | 57 ms | 6784 KB | Output is correct |
50 | Correct | 191 ms | 25928 KB | Output is correct |
51 | Correct | 192 ms | 25900 KB | Output is correct |
52 | Correct | 170 ms | 26132 KB | Output is correct |
53 | Correct | 56 ms | 16184 KB | Output is correct |
54 | Correct | 82 ms | 16144 KB | Output is correct |
55 | Correct | 181 ms | 25928 KB | Output is correct |
56 | Correct | 169 ms | 26140 KB | Output is correct |
57 | Correct | 129 ms | 16148 KB | Output is correct |
58 | Correct | 1 ms | 336 KB | Output is correct |
59 | Correct | 1 ms | 336 KB | Output is correct |
60 | Correct | 1 ms | 504 KB | Output is correct |
61 | Correct | 47 ms | 6728 KB | Output is correct |
62 | Correct | 193 ms | 26140 KB | Output is correct |
63 | Correct | 166 ms | 26136 KB | Output is correct |
64 | Correct | 169 ms | 26184 KB | Output is correct |
65 | Correct | 1 ms | 336 KB | Output is correct |
66 | Correct | 39 ms | 6792 KB | Output is correct |
67 | Correct | 174 ms | 26084 KB | Output is correct |
68 | Correct | 181 ms | 25928 KB | Output is correct |
69 | Correct | 150 ms | 26136 KB | Output is correct |
70 | Correct | 1 ms | 336 KB | Output is correct |
71 | Correct | 1 ms | 336 KB | Output is correct |
72 | Correct | 1 ms | 336 KB | Output is correct |
73 | Correct | 42 ms | 6768 KB | Output is correct |
74 | Correct | 139 ms | 26140 KB | Output is correct |
75 | Correct | 158 ms | 26140 KB | Output is correct |
76 | Correct | 174 ms | 26140 KB | Output is correct |
77 | Correct | 166 ms | 26136 KB | Output is correct |
78 | Correct | 1 ms | 772 KB | Output is correct |
79 | Correct | 1 ms | 336 KB | Output is correct |
80 | Correct | 6 ms | 1104 KB | Output is correct |
81 | Correct | 82 ms | 18108 KB | Output is correct |
82 | Correct | 1 ms | 592 KB | Output is correct |
83 | Correct | 1 ms | 336 KB | Output is correct |
84 | Correct | 1 ms | 336 KB | Output is correct |
85 | Correct | 48 ms | 7256 KB | Output is correct |
86 | Correct | 106 ms | 18104 KB | Output is correct |
87 | Correct | 86 ms | 17992 KB | Output is correct |
88 | Correct | 78 ms | 18188 KB | Output is correct |
89 | Correct | 60 ms | 17988 KB | Output is correct |
90 | Correct | 1 ms | 336 KB | Output is correct |
91 | Correct | 1 ms | 336 KB | Output is correct |
92 | Correct | 4 ms | 1104 KB | Output is correct |
93 | Correct | 85 ms | 18248 KB | Output is correct |
94 | Correct | 1 ms | 336 KB | Output is correct |
95 | Correct | 1 ms | 336 KB | Output is correct |
96 | Correct | 1 ms | 592 KB | Output is correct |
97 | Correct | 19 ms | 4740 KB | Output is correct |
98 | Correct | 86 ms | 18248 KB | Output is correct |
99 | Correct | 86 ms | 18184 KB | Output is correct |
100 | Correct | 62 ms | 18188 KB | Output is correct |
101 | Correct | 93 ms | 18052 KB | Output is correct |
102 | Correct | 83 ms | 18184 KB | Output is correct |
103 | Correct | 79 ms | 18056 KB | Output is correct |
104 | Correct | 89 ms | 18056 KB | Output is correct |
105 | Correct | 78 ms | 18064 KB | Output is correct |