# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
625305 | 2022-08-10T01:14:58 Z | Trunkty | 슈퍼트리 잇기 (IOI20_supertrees) | C++14 | 224 ms | 22156 KB |
#include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; typedef long long ll; //#define int ll #include "supertrees.h" int root[1005]; vector<int> ans[1005]; int rootp[1005]; vector<int> part[1005]; int findroot(int x){ if(root[x]!=x){ root[x] = findroot(root[x]); } return root[x]; } void domerge(int a, int b){ a = findroot(a); b = findroot(b); root[a] = b; } int findrootp(int x){ if(rootp[x]!=x){ rootp[x] = findrootp(rootp[x]); } return rootp[x]; } void domergep(int a, int b){ a = findrootp(a); b = findrootp(b); rootp[a] = b; } int construct(vector<vector<int>> p) { int n = p.size(); vector<vector<int>> ret; for (int i = 0; i < n; i++) { vector<int> row; row.resize(n); ret.push_back(row); } for(int i=0;i<n;i++){ root[i] = i; rootp[i] = i; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(p[i][j]){ domerge(i,j); } if(p[i][j]==1){ domergep(i,j); } if(p[i][j]==3){ return 0; } } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(p[i][j]==0 and findroot(i)==findroot(j)){ return 0; } if(p[i][j]==2 and findrootp(i)==findrootp(j)){ return 0; } } } for(int i=0;i<n;i++){ ans[findroot(i)].push_back(i); part[findrootp(i)].push_back(i); } for(int i=0;i<n;i++){ for(int j=1;j<part[i].size();j++){ ret[part[i][j-1]][part[i][j]] = 1; ret[part[i][j]][part[i][j-1]] = 1; } } for(int i=0;i<n;i++){ set<int> s; vector<int> v; for(int j=0;j<ans[i].size();j++){ s.insert(findrootp(ans[i][j])); } for(int j:s){ v.push_back(j); } for(int j=1;j<v.size();j++){ ret[v[j]][v[j-1]] = 1; ret[v[j-1]][v[j]] = 1; } if(v.size()<=1){ continue; } else if(v.size()==2){ return 0; } ret[v[0]][v.back()] = 1; ret[v.back()][v[0]] = 1; } build(ret); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 7 ms | 1252 KB | Output is correct |
7 | Correct | 191 ms | 22056 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 7 ms | 1252 KB | Output is correct |
7 | Correct | 191 ms | 22056 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 7 ms | 1236 KB | Output is correct |
13 | Correct | 164 ms | 22072 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 4 ms | 744 KB | Output is correct |
17 | Correct | 85 ms | 12088 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 46 ms | 5820 KB | Output is correct |
21 | Correct | 171 ms | 22056 KB | Output is correct |
22 | Correct | 190 ms | 22008 KB | Output is correct |
23 | Correct | 175 ms | 22076 KB | Output is correct |
24 | Correct | 169 ms | 22104 KB | Output is correct |
25 | Correct | 67 ms | 12092 KB | Output is correct |
26 | Correct | 69 ms | 12100 KB | Output is correct |
27 | Correct | 204 ms | 22076 KB | Output is correct |
28 | Correct | 167 ms | 22096 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 428 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 7 ms | 1236 KB | Output is correct |
9 | Correct | 164 ms | 22144 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 8 ms | 1244 KB | Output is correct |
13 | Correct | 224 ms | 22156 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 4 ms | 724 KB | Output is correct |
17 | Correct | 91 ms | 12092 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 44 ms | 5828 KB | Output is correct |
22 | Correct | 172 ms | 22152 KB | Output is correct |
23 | Correct | 178 ms | 22096 KB | Output is correct |
24 | Correct | 197 ms | 22148 KB | Output is correct |
25 | Correct | 72 ms | 12216 KB | Output is correct |
26 | Correct | 66 ms | 12104 KB | Output is correct |
27 | Correct | 175 ms | 22080 KB | Output is correct |
28 | Correct | 184 ms | 22076 KB | Output is correct |
29 | Correct | 93 ms | 12216 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 47 ms | 5744 KB | Output is correct |
5 | Correct | 215 ms | 22072 KB | Output is correct |
6 | Correct | 203 ms | 22136 KB | Output is correct |
7 | Correct | 206 ms | 22084 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 44 ms | 5836 KB | Output is correct |
10 | Correct | 212 ms | 22088 KB | Output is correct |
11 | Correct | 169 ms | 22068 KB | Output is correct |
12 | Correct | 191 ms | 22084 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 47 ms | 5808 KB | Output is correct |
17 | Correct | 206 ms | 22080 KB | Output is correct |
18 | Correct | 178 ms | 22128 KB | Output is correct |
19 | Correct | 170 ms | 22076 KB | Output is correct |
20 | Correct | 174 ms | 22156 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 7 ms | 1252 KB | Output is correct |
7 | Correct | 191 ms | 22056 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 7 ms | 1236 KB | Output is correct |
13 | Correct | 164 ms | 22072 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 4 ms | 744 KB | Output is correct |
17 | Correct | 85 ms | 12088 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 46 ms | 5820 KB | Output is correct |
21 | Correct | 171 ms | 22056 KB | Output is correct |
22 | Correct | 190 ms | 22008 KB | Output is correct |
23 | Correct | 175 ms | 22076 KB | Output is correct |
24 | Correct | 169 ms | 22104 KB | Output is correct |
25 | Correct | 67 ms | 12092 KB | Output is correct |
26 | Correct | 69 ms | 12100 KB | Output is correct |
27 | Correct | 204 ms | 22076 KB | Output is correct |
28 | Correct | 167 ms | 22096 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 0 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 428 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 7 ms | 1236 KB | Output is correct |
37 | Correct | 164 ms | 22144 KB | Output is correct |
38 | Correct | 1 ms | 348 KB | Output is correct |
39 | Correct | 1 ms | 348 KB | Output is correct |
40 | Correct | 8 ms | 1244 KB | Output is correct |
41 | Correct | 224 ms | 22156 KB | Output is correct |
42 | Correct | 1 ms | 340 KB | Output is correct |
43 | Correct | 0 ms | 340 KB | Output is correct |
44 | Correct | 4 ms | 724 KB | Output is correct |
45 | Correct | 91 ms | 12092 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 0 ms | 348 KB | Output is correct |
48 | Correct | 1 ms | 348 KB | Output is correct |
49 | Correct | 44 ms | 5828 KB | Output is correct |
50 | Correct | 172 ms | 22152 KB | Output is correct |
51 | Correct | 178 ms | 22096 KB | Output is correct |
52 | Correct | 197 ms | 22148 KB | Output is correct |
53 | Correct | 72 ms | 12216 KB | Output is correct |
54 | Correct | 66 ms | 12104 KB | Output is correct |
55 | Correct | 175 ms | 22080 KB | Output is correct |
56 | Correct | 184 ms | 22076 KB | Output is correct |
57 | Correct | 93 ms | 12216 KB | Output is correct |
58 | Correct | 0 ms | 340 KB | Output is correct |
59 | Correct | 0 ms | 340 KB | Output is correct |
60 | Correct | 4 ms | 724 KB | Output is correct |
61 | Correct | 80 ms | 12096 KB | Output is correct |
62 | Correct | 0 ms | 340 KB | Output is correct |
63 | Correct | 0 ms | 340 KB | Output is correct |
64 | Correct | 0 ms | 340 KB | Output is correct |
65 | Correct | 52 ms | 5800 KB | Output is correct |
66 | Correct | 75 ms | 12224 KB | Output is correct |
67 | Correct | 69 ms | 12108 KB | Output is correct |
68 | Correct | 66 ms | 12104 KB | Output is correct |
69 | Correct | 80 ms | 12220 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 7 ms | 1252 KB | Output is correct |
7 | Correct | 191 ms | 22056 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 7 ms | 1236 KB | Output is correct |
13 | Correct | 164 ms | 22072 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 4 ms | 744 KB | Output is correct |
17 | Correct | 85 ms | 12088 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 46 ms | 5820 KB | Output is correct |
21 | Correct | 171 ms | 22056 KB | Output is correct |
22 | Correct | 190 ms | 22008 KB | Output is correct |
23 | Correct | 175 ms | 22076 KB | Output is correct |
24 | Correct | 169 ms | 22104 KB | Output is correct |
25 | Correct | 67 ms | 12092 KB | Output is correct |
26 | Correct | 69 ms | 12100 KB | Output is correct |
27 | Correct | 204 ms | 22076 KB | Output is correct |
28 | Correct | 167 ms | 22096 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 0 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 428 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 7 ms | 1236 KB | Output is correct |
37 | Correct | 164 ms | 22144 KB | Output is correct |
38 | Correct | 1 ms | 348 KB | Output is correct |
39 | Correct | 1 ms | 348 KB | Output is correct |
40 | Correct | 8 ms | 1244 KB | Output is correct |
41 | Correct | 224 ms | 22156 KB | Output is correct |
42 | Correct | 1 ms | 340 KB | Output is correct |
43 | Correct | 0 ms | 340 KB | Output is correct |
44 | Correct | 4 ms | 724 KB | Output is correct |
45 | Correct | 91 ms | 12092 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 0 ms | 348 KB | Output is correct |
48 | Correct | 1 ms | 348 KB | Output is correct |
49 | Correct | 44 ms | 5828 KB | Output is correct |
50 | Correct | 172 ms | 22152 KB | Output is correct |
51 | Correct | 178 ms | 22096 KB | Output is correct |
52 | Correct | 197 ms | 22148 KB | Output is correct |
53 | Correct | 72 ms | 12216 KB | Output is correct |
54 | Correct | 66 ms | 12104 KB | Output is correct |
55 | Correct | 175 ms | 22080 KB | Output is correct |
56 | Correct | 184 ms | 22076 KB | Output is correct |
57 | Correct | 93 ms | 12216 KB | Output is correct |
58 | Correct | 1 ms | 340 KB | Output is correct |
59 | Correct | 0 ms | 340 KB | Output is correct |
60 | Correct | 1 ms | 340 KB | Output is correct |
61 | Correct | 47 ms | 5744 KB | Output is correct |
62 | Correct | 215 ms | 22072 KB | Output is correct |
63 | Correct | 203 ms | 22136 KB | Output is correct |
64 | Correct | 206 ms | 22084 KB | Output is correct |
65 | Correct | 0 ms | 340 KB | Output is correct |
66 | Correct | 44 ms | 5836 KB | Output is correct |
67 | Correct | 212 ms | 22088 KB | Output is correct |
68 | Correct | 169 ms | 22068 KB | Output is correct |
69 | Correct | 191 ms | 22084 KB | Output is correct |
70 | Correct | 1 ms | 340 KB | Output is correct |
71 | Correct | 0 ms | 340 KB | Output is correct |
72 | Correct | 0 ms | 340 KB | Output is correct |
73 | Correct | 47 ms | 5808 KB | Output is correct |
74 | Correct | 206 ms | 22080 KB | Output is correct |
75 | Correct | 178 ms | 22128 KB | Output is correct |
76 | Correct | 170 ms | 22076 KB | Output is correct |
77 | Correct | 174 ms | 22156 KB | Output is correct |
78 | Correct | 0 ms | 340 KB | Output is correct |
79 | Correct | 0 ms | 340 KB | Output is correct |
80 | Correct | 4 ms | 724 KB | Output is correct |
81 | Correct | 80 ms | 12096 KB | Output is correct |
82 | Correct | 0 ms | 340 KB | Output is correct |
83 | Correct | 0 ms | 340 KB | Output is correct |
84 | Correct | 0 ms | 340 KB | Output is correct |
85 | Correct | 52 ms | 5800 KB | Output is correct |
86 | Correct | 75 ms | 12224 KB | Output is correct |
87 | Correct | 69 ms | 12108 KB | Output is correct |
88 | Correct | 66 ms | 12104 KB | Output is correct |
89 | Correct | 80 ms | 12220 KB | Output is correct |
90 | Correct | 0 ms | 340 KB | Output is correct |
91 | Correct | 0 ms | 340 KB | Output is correct |
92 | Correct | 4 ms | 724 KB | Output is correct |
93 | Correct | 78 ms | 12088 KB | Output is correct |
94 | Correct | 0 ms | 340 KB | Output is correct |
95 | Correct | 1 ms | 340 KB | Output is correct |
96 | Correct | 0 ms | 340 KB | Output is correct |
97 | Correct | 17 ms | 3760 KB | Output is correct |
98 | Correct | 67 ms | 14120 KB | Output is correct |
99 | Correct | 88 ms | 14128 KB | Output is correct |
100 | Correct | 70 ms | 14056 KB | Output is correct |
101 | Correct | 65 ms | 14124 KB | Output is correct |
102 | Correct | 69 ms | 14128 KB | Output is correct |
103 | Correct | 69 ms | 14120 KB | Output is correct |
104 | Correct | 69 ms | 14124 KB | Output is correct |
105 | Correct | 73 ms | 14136 KB | Output is correct |