# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1046557 | 2024-08-06T16:49:12 Z | sofijavelkovska | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 127 ms | 22400 KB |
#include "supertrees.h" //#include "grader.cpp" #include <bits/stdc++.h> using namespace std; int construct(vector<vector<int> > adj) { int n=adj.size(); vector<vector<int> > answer; for (int i=0; i<n; i++) { vector<int> row; row.resize(n, 0); answer.push_back(row); } for (int i=0; i<n; i++) for (int j=i+1; j<n; j++) if (adj[i][j]==3) return 0; int visited[n]={0}; queue<int> q; vector<int> component; vector<vector<int> > subcomponents; for (int i=0; i<n; i++) { if (visited[i]) continue; visited[i]=1; q.push(i); component.clear(); while (!q.empty()) { int x=q.front(); q.pop(); component.push_back(x); for (int j=0; j<n; j++) if (adj[x][j]>0 && !visited[j]) { visited[j]=1; q.push(j); } } subcomponents.clear(); for (auto x : component) { if (visited[x]==2) continue; visited[x]=2; q.push(x); vector<int> newcomp; subcomponents.push_back(newcomp); while (!q.empty()) { int y=q.front(); q.pop(); subcomponents.back().push_back(y); for (auto z : component) if (y!=z && adj[y][z]==1 && visited[z]!=2) { visited[z]=2; q.push(z); } } } for (int j=0; j<subcomponents.size(); j++) { for (int t=0; t<subcomponents[j].size(); t++) for (int k=t+1; k<subcomponents[j].size(); k++) if (adj[subcomponents[j][t]][subcomponents[j][k]]!=1) return 0; for (auto x : subcomponents[j]) for (int t=0; t<subcomponents.size(); t++) { if (t==j) continue; for (auto y : subcomponents[t]) if (adj[x][y]!=2) return 0; } } if (subcomponents.size()==2) { for (int j=0; j<component.size(); j++) for (int t=j+1; t<component.size(); t++) if (adj[j][t]!=1) return 0; } for (int j=0; j<subcomponents.size(); j++) for (int t=0; t<subcomponents[j].size()-1; t++) { int x=subcomponents[j][t]; int y=subcomponents[j][t+1]; answer[x][y]=1; answer[y][x]=1; } if (subcomponents.size()==1) continue; if (subcomponents.size()==2) { int x=subcomponents[0][0]; int y=subcomponents[1][0]; answer[x][y]=1; answer[y][x]=1; } for (int j=0; j<subcomponents.size(); j++) { int x=subcomponents[j][0]; int y=subcomponents[(j+1)%subcomponents.size()][0]; answer[x][y]=1; answer[y][x]=1; } } build(answer); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 4 ms | 1116 KB | Output is correct |
7 | Correct | 97 ms | 22124 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 4 ms | 1116 KB | Output is correct |
7 | Correct | 97 ms | 22124 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 4 ms | 1112 KB | Output is correct |
13 | Correct | 103 ms | 21964 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 860 KB | Output is correct |
17 | Correct | 57 ms | 12116 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 24 ms | 5900 KB | Output is correct |
21 | Correct | 102 ms | 22112 KB | Output is correct |
22 | Correct | 97 ms | 22004 KB | Output is correct |
23 | Correct | 104 ms | 22100 KB | Output is correct |
24 | Correct | 101 ms | 22036 KB | Output is correct |
25 | Correct | 43 ms | 12116 KB | Output is correct |
26 | Correct | 41 ms | 12124 KB | Output is correct |
27 | Correct | 99 ms | 22148 KB | Output is correct |
28 | Correct | 97 ms | 22116 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 4 ms | 1144 KB | Output is correct |
9 | Correct | 95 ms | 21944 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 5 ms | 1116 KB | Output is correct |
13 | Correct | 98 ms | 22100 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 856 KB | Output is correct |
17 | Correct | 59 ms | 12312 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 24 ms | 5780 KB | Output is correct |
22 | Correct | 97 ms | 22100 KB | Output is correct |
23 | Correct | 97 ms | 22040 KB | Output is correct |
24 | Correct | 106 ms | 22088 KB | Output is correct |
25 | Correct | 41 ms | 12040 KB | Output is correct |
26 | Correct | 61 ms | 12052 KB | Output is correct |
27 | Correct | 96 ms | 21956 KB | Output is correct |
28 | Correct | 107 ms | 22400 KB | Output is correct |
29 | Correct | 43 ms | 12368 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 24 ms | 5924 KB | Output is correct |
5 | Correct | 99 ms | 21968 KB | Output is correct |
6 | Correct | 95 ms | 22188 KB | Output is correct |
7 | Correct | 107 ms | 22032 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 25 ms | 5876 KB | Output is correct |
10 | Correct | 108 ms | 22100 KB | Output is correct |
11 | Correct | 96 ms | 22040 KB | Output is correct |
12 | Correct | 103 ms | 22040 KB | Output is correct |
13 | Correct | 1 ms | 600 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 33 ms | 5716 KB | Output is correct |
17 | Correct | 101 ms | 22100 KB | Output is correct |
18 | Correct | 97 ms | 22156 KB | Output is correct |
19 | Correct | 127 ms | 22100 KB | Output is correct |
20 | Correct | 95 ms | 22096 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 4 ms | 1116 KB | Output is correct |
7 | Correct | 97 ms | 22124 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 4 ms | 1112 KB | Output is correct |
13 | Correct | 103 ms | 21964 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 860 KB | Output is correct |
17 | Correct | 57 ms | 12116 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 24 ms | 5900 KB | Output is correct |
21 | Correct | 102 ms | 22112 KB | Output is correct |
22 | Correct | 97 ms | 22004 KB | Output is correct |
23 | Correct | 104 ms | 22100 KB | Output is correct |
24 | Correct | 101 ms | 22036 KB | Output is correct |
25 | Correct | 43 ms | 12116 KB | Output is correct |
26 | Correct | 41 ms | 12124 KB | Output is correct |
27 | Correct | 99 ms | 22148 KB | Output is correct |
28 | Correct | 97 ms | 22116 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 344 KB | Output is correct |
36 | Correct | 4 ms | 1144 KB | Output is correct |
37 | Correct | 95 ms | 21944 KB | Output is correct |
38 | Correct | 0 ms | 344 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 5 ms | 1116 KB | Output is correct |
41 | Correct | 98 ms | 22100 KB | Output is correct |
42 | Correct | 0 ms | 344 KB | Output is correct |
43 | Correct | 1 ms | 348 KB | Output is correct |
44 | Correct | 3 ms | 856 KB | Output is correct |
45 | Correct | 59 ms | 12312 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 1 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 348 KB | Output is correct |
49 | Correct | 24 ms | 5780 KB | Output is correct |
50 | Correct | 97 ms | 22100 KB | Output is correct |
51 | Correct | 97 ms | 22040 KB | Output is correct |
52 | Correct | 106 ms | 22088 KB | Output is correct |
53 | Correct | 41 ms | 12040 KB | Output is correct |
54 | Correct | 61 ms | 12052 KB | Output is correct |
55 | Correct | 96 ms | 21956 KB | Output is correct |
56 | Correct | 107 ms | 22400 KB | Output is correct |
57 | Correct | 43 ms | 12368 KB | Output is correct |
58 | Correct | 0 ms | 348 KB | Output is correct |
59 | Correct | 0 ms | 348 KB | Output is correct |
60 | Correct | 3 ms | 856 KB | Output is correct |
61 | Correct | 52 ms | 12052 KB | Output is correct |
62 | Correct | 0 ms | 348 KB | Output is correct |
63 | Correct | 0 ms | 348 KB | Output is correct |
64 | Correct | 0 ms | 348 KB | Output is correct |
65 | Correct | 24 ms | 5724 KB | Output is correct |
66 | Correct | 44 ms | 12052 KB | Output is correct |
67 | Correct | 46 ms | 12116 KB | Output is correct |
68 | Correct | 42 ms | 12116 KB | Output is correct |
69 | Correct | 42 ms | 12056 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 4 ms | 1116 KB | Output is correct |
7 | Correct | 97 ms | 22124 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 4 ms | 1112 KB | Output is correct |
13 | Correct | 103 ms | 21964 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 860 KB | Output is correct |
17 | Correct | 57 ms | 12116 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 24 ms | 5900 KB | Output is correct |
21 | Correct | 102 ms | 22112 KB | Output is correct |
22 | Correct | 97 ms | 22004 KB | Output is correct |
23 | Correct | 104 ms | 22100 KB | Output is correct |
24 | Correct | 101 ms | 22036 KB | Output is correct |
25 | Correct | 43 ms | 12116 KB | Output is correct |
26 | Correct | 41 ms | 12124 KB | Output is correct |
27 | Correct | 99 ms | 22148 KB | Output is correct |
28 | Correct | 97 ms | 22116 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 344 KB | Output is correct |
36 | Correct | 4 ms | 1144 KB | Output is correct |
37 | Correct | 95 ms | 21944 KB | Output is correct |
38 | Correct | 0 ms | 344 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 5 ms | 1116 KB | Output is correct |
41 | Correct | 98 ms | 22100 KB | Output is correct |
42 | Correct | 0 ms | 344 KB | Output is correct |
43 | Correct | 1 ms | 348 KB | Output is correct |
44 | Correct | 3 ms | 856 KB | Output is correct |
45 | Correct | 59 ms | 12312 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 1 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 348 KB | Output is correct |
49 | Correct | 24 ms | 5780 KB | Output is correct |
50 | Correct | 97 ms | 22100 KB | Output is correct |
51 | Correct | 97 ms | 22040 KB | Output is correct |
52 | Correct | 106 ms | 22088 KB | Output is correct |
53 | Correct | 41 ms | 12040 KB | Output is correct |
54 | Correct | 61 ms | 12052 KB | Output is correct |
55 | Correct | 96 ms | 21956 KB | Output is correct |
56 | Correct | 107 ms | 22400 KB | Output is correct |
57 | Correct | 43 ms | 12368 KB | Output is correct |
58 | Correct | 0 ms | 348 KB | Output is correct |
59 | Correct | 0 ms | 348 KB | Output is correct |
60 | Correct | 0 ms | 348 KB | Output is correct |
61 | Correct | 24 ms | 5924 KB | Output is correct |
62 | Correct | 99 ms | 21968 KB | Output is correct |
63 | Correct | 95 ms | 22188 KB | Output is correct |
64 | Correct | 107 ms | 22032 KB | Output is correct |
65 | Correct | 1 ms | 348 KB | Output is correct |
66 | Correct | 25 ms | 5876 KB | Output is correct |
67 | Correct | 108 ms | 22100 KB | Output is correct |
68 | Correct | 96 ms | 22040 KB | Output is correct |
69 | Correct | 103 ms | 22040 KB | Output is correct |
70 | Correct | 1 ms | 600 KB | Output is correct |
71 | Correct | 0 ms | 348 KB | Output is correct |
72 | Correct | 0 ms | 348 KB | Output is correct |
73 | Correct | 33 ms | 5716 KB | Output is correct |
74 | Correct | 101 ms | 22100 KB | Output is correct |
75 | Correct | 97 ms | 22156 KB | Output is correct |
76 | Correct | 127 ms | 22100 KB | Output is correct |
77 | Correct | 95 ms | 22096 KB | Output is correct |
78 | Correct | 0 ms | 348 KB | Output is correct |
79 | Correct | 0 ms | 348 KB | Output is correct |
80 | Correct | 3 ms | 856 KB | Output is correct |
81 | Correct | 52 ms | 12052 KB | Output is correct |
82 | Correct | 0 ms | 348 KB | Output is correct |
83 | Correct | 0 ms | 348 KB | Output is correct |
84 | Correct | 0 ms | 348 KB | Output is correct |
85 | Correct | 24 ms | 5724 KB | Output is correct |
86 | Correct | 44 ms | 12052 KB | Output is correct |
87 | Correct | 46 ms | 12116 KB | Output is correct |
88 | Correct | 42 ms | 12116 KB | Output is correct |
89 | Correct | 42 ms | 12056 KB | Output is correct |
90 | Correct | 0 ms | 344 KB | Output is correct |
91 | Correct | 0 ms | 344 KB | Output is correct |
92 | Correct | 2 ms | 860 KB | Output is correct |
93 | Correct | 44 ms | 12056 KB | Output is correct |
94 | Correct | 0 ms | 348 KB | Output is correct |
95 | Correct | 0 ms | 348 KB | Output is correct |
96 | Correct | 0 ms | 348 KB | Output is correct |
97 | Correct | 11 ms | 3420 KB | Output is correct |
98 | Correct | 46 ms | 12060 KB | Output is correct |
99 | Correct | 42 ms | 12112 KB | Output is correct |
100 | Correct | 42 ms | 12120 KB | Output is correct |
101 | Correct | 41 ms | 12116 KB | Output is correct |
102 | Correct | 40 ms | 12116 KB | Output is correct |
103 | Correct | 41 ms | 12120 KB | Output is correct |
104 | Correct | 42 ms | 12116 KB | Output is correct |
105 | Correct | 46 ms | 12112 KB | Output is correct |