# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
377355 | 2021-03-14T04:41:31 Z | Thistle | 슈퍼트리 잇기 (IOI20_supertrees) | C++14 | 283 ms | 22252 KB |
#include "supertrees.h" #include <vector> #include<algorithm> #include<set> #include<iostream> using namespace std; using ll=long long; using H=pair<ll, ll>; #define vec vector #define vi vec<ll> #define pb push_back #define all(a) (a).begin(),(a).end() #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define rep(i,n) rng((i),0,(n)) #define siz(a) int((a).size()) class unionfind{ int n; vi pa,sz; public: unionfind(int n):n(n){ pa.resize(n); sz.assign(n,1); rep(i,n) pa[i]=i; } int root(int x){ if(pa[x]==x) return x; return pa[x]=root(pa[x]); } void unite(int x,int y){ x=root(x);y=root(y); if(x==y) return; if(sz[x]>sz[y]) swap(x,y); sz[y]+=sz[x]; pa[x]=y; } }; int construct(std::vector<std::vector<int>> p) { int n = p.size(); //hanteiwo suru unionfind uf(n); rep(i,n)rep(j,n){ if(p[i][j]==3) return 0; if(p[i][j]) uf.unite(i,j); } rep(i,n)rep(j,n){ if(uf.root(i)==uf.root(j)&&p[i][j]==0){ return 0; } } //seihoukei no shuugou desuka? vec<vec<int>>answer(n,vec<int>(n,0)); vec<int>used(n,-1);int time2=0; vec<bool>used2(n,0); vi used3(n,-1); int time=0; rep(x,n){ if(~used[x]) continue; vi v; rep(i,n){ if(p[i][x]) { v.pb(i); used[i]=time2; } } for(auto g:v)for(auto r:v){ if(p[g][r]==0) return 0; } for(auto g:v)rep(i,n){ if(p[g][i]&&used[i]!=time2) return 0; if(used[i]==time2&&p[g][i]==0) return 0; } time2++; //seihoukei desuka? vi cic; for(auto g:v){ if(used2[g]) continue; vi u; for(auto r:v){ if(p[g][r]==1){ u.pb(r); used2[r]=1; used3[r]=time; } } //koitura ha hokani 1 wo motte inaika? for(auto g:u){ rep(i,n){ if(p[i][g]==1&&used3[i]!=time){ return 0; } if(used3[i]==time&&p[i][g]!=1){ return 0; } } } rep(i,siz(u)-1){ answer[u[i]][u[i+1]]=answer[u[i+1]][u[i]]=1; } cic.pb(u[0]); time++; } rep(i,siz(cic)-1){ answer[cic[i]][cic[i+1]]=answer[cic[i+1]][cic[i]]=1; } if(siz(cic)==2) return 0; if(siz(cic)>1){ answer[cic[0]][cic[siz(cic)-1]]= answer[cic[siz(cic)-1]][cic[0]]=1; } } build(answer); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 11 ms | 1260 KB | Output is correct |
7 | Correct | 262 ms | 22124 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 11 ms | 1260 KB | Output is correct |
7 | Correct | 262 ms | 22124 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 11 ms | 1260 KB | Output is correct |
13 | Correct | 263 ms | 22124 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 6 ms | 620 KB | Output is correct |
17 | Correct | 112 ms | 8172 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 67 ms | 5868 KB | Output is correct |
21 | Correct | 261 ms | 22124 KB | Output is correct |
22 | Correct | 266 ms | 22140 KB | Output is correct |
23 | Correct | 272 ms | 22180 KB | Output is correct |
24 | Correct | 256 ms | 22124 KB | Output is correct |
25 | Correct | 101 ms | 8192 KB | Output is correct |
26 | Correct | 99 ms | 8172 KB | Output is correct |
27 | Correct | 268 ms | 22124 KB | Output is correct |
28 | Correct | 264 ms | 22124 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 11 ms | 1260 KB | Output is correct |
9 | Correct | 254 ms | 22124 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 11 ms | 1260 KB | Output is correct |
13 | Correct | 263 ms | 22124 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 5 ms | 620 KB | Output is correct |
17 | Correct | 112 ms | 8172 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 68 ms | 5868 KB | Output is correct |
22 | Correct | 265 ms | 22124 KB | Output is correct |
23 | Correct | 260 ms | 22124 KB | Output is correct |
24 | Correct | 270 ms | 22124 KB | Output is correct |
25 | Correct | 106 ms | 12128 KB | Output is correct |
26 | Correct | 102 ms | 8172 KB | Output is correct |
27 | Correct | 257 ms | 22124 KB | Output is correct |
28 | Correct | 272 ms | 22124 KB | Output is correct |
29 | Correct | 107 ms | 12140 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 66 ms | 5868 KB | Output is correct |
5 | Correct | 260 ms | 22124 KB | Output is correct |
6 | Correct | 261 ms | 22124 KB | Output is correct |
7 | Correct | 274 ms | 22112 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 65 ms | 5868 KB | Output is correct |
10 | Correct | 262 ms | 22252 KB | Output is correct |
11 | Correct | 261 ms | 22124 KB | Output is correct |
12 | Correct | 273 ms | 22124 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 67 ms | 5868 KB | Output is correct |
17 | Correct | 261 ms | 22124 KB | Output is correct |
18 | Correct | 283 ms | 22252 KB | Output is correct |
19 | Correct | 261 ms | 22252 KB | Output is correct |
20 | Correct | 257 ms | 22124 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 11 ms | 1260 KB | Output is correct |
7 | Correct | 262 ms | 22124 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 11 ms | 1260 KB | Output is correct |
13 | Correct | 263 ms | 22124 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 6 ms | 620 KB | Output is correct |
17 | Correct | 112 ms | 8172 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 67 ms | 5868 KB | Output is correct |
21 | Correct | 261 ms | 22124 KB | Output is correct |
22 | Correct | 266 ms | 22140 KB | Output is correct |
23 | Correct | 272 ms | 22180 KB | Output is correct |
24 | Correct | 256 ms | 22124 KB | Output is correct |
25 | Correct | 101 ms | 8192 KB | Output is correct |
26 | Correct | 99 ms | 8172 KB | Output is correct |
27 | Correct | 268 ms | 22124 KB | Output is correct |
28 | Correct | 264 ms | 22124 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 0 ms | 364 KB | Output is correct |
32 | Correct | 1 ms | 384 KB | Output is correct |
33 | Correct | 1 ms | 364 KB | Output is correct |
34 | Correct | 0 ms | 364 KB | Output is correct |
35 | Correct | 1 ms | 364 KB | Output is correct |
36 | Correct | 11 ms | 1260 KB | Output is correct |
37 | Correct | 254 ms | 22124 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 1 ms | 364 KB | Output is correct |
40 | Correct | 11 ms | 1260 KB | Output is correct |
41 | Correct | 263 ms | 22124 KB | Output is correct |
42 | Correct | 1 ms | 364 KB | Output is correct |
43 | Correct | 1 ms | 364 KB | Output is correct |
44 | Correct | 5 ms | 620 KB | Output is correct |
45 | Correct | 112 ms | 8172 KB | Output is correct |
46 | Correct | 1 ms | 364 KB | Output is correct |
47 | Correct | 1 ms | 364 KB | Output is correct |
48 | Correct | 1 ms | 364 KB | Output is correct |
49 | Correct | 68 ms | 5868 KB | Output is correct |
50 | Correct | 265 ms | 22124 KB | Output is correct |
51 | Correct | 260 ms | 22124 KB | Output is correct |
52 | Correct | 270 ms | 22124 KB | Output is correct |
53 | Correct | 106 ms | 12128 KB | Output is correct |
54 | Correct | 102 ms | 8172 KB | Output is correct |
55 | Correct | 257 ms | 22124 KB | Output is correct |
56 | Correct | 272 ms | 22124 KB | Output is correct |
57 | Correct | 107 ms | 12140 KB | Output is correct |
58 | Correct | 1 ms | 364 KB | Output is correct |
59 | Correct | 0 ms | 364 KB | Output is correct |
60 | Correct | 7 ms | 620 KB | Output is correct |
61 | Correct | 110 ms | 8300 KB | Output is correct |
62 | Correct | 1 ms | 364 KB | Output is correct |
63 | Correct | 1 ms | 364 KB | Output is correct |
64 | Correct | 1 ms | 364 KB | Output is correct |
65 | Correct | 67 ms | 5868 KB | Output is correct |
66 | Correct | 100 ms | 8172 KB | Output is correct |
67 | Correct | 105 ms | 8172 KB | Output is correct |
68 | Correct | 99 ms | 8172 KB | Output is correct |
69 | Correct | 103 ms | 12140 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 11 ms | 1260 KB | Output is correct |
7 | Correct | 262 ms | 22124 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 11 ms | 1260 KB | Output is correct |
13 | Correct | 263 ms | 22124 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 6 ms | 620 KB | Output is correct |
17 | Correct | 112 ms | 8172 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 67 ms | 5868 KB | Output is correct |
21 | Correct | 261 ms | 22124 KB | Output is correct |
22 | Correct | 266 ms | 22140 KB | Output is correct |
23 | Correct | 272 ms | 22180 KB | Output is correct |
24 | Correct | 256 ms | 22124 KB | Output is correct |
25 | Correct | 101 ms | 8192 KB | Output is correct |
26 | Correct | 99 ms | 8172 KB | Output is correct |
27 | Correct | 268 ms | 22124 KB | Output is correct |
28 | Correct | 264 ms | 22124 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 0 ms | 364 KB | Output is correct |
32 | Correct | 1 ms | 384 KB | Output is correct |
33 | Correct | 1 ms | 364 KB | Output is correct |
34 | Correct | 0 ms | 364 KB | Output is correct |
35 | Correct | 1 ms | 364 KB | Output is correct |
36 | Correct | 11 ms | 1260 KB | Output is correct |
37 | Correct | 254 ms | 22124 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 1 ms | 364 KB | Output is correct |
40 | Correct | 11 ms | 1260 KB | Output is correct |
41 | Correct | 263 ms | 22124 KB | Output is correct |
42 | Correct | 1 ms | 364 KB | Output is correct |
43 | Correct | 1 ms | 364 KB | Output is correct |
44 | Correct | 5 ms | 620 KB | Output is correct |
45 | Correct | 112 ms | 8172 KB | Output is correct |
46 | Correct | 1 ms | 364 KB | Output is correct |
47 | Correct | 1 ms | 364 KB | Output is correct |
48 | Correct | 1 ms | 364 KB | Output is correct |
49 | Correct | 68 ms | 5868 KB | Output is correct |
50 | Correct | 265 ms | 22124 KB | Output is correct |
51 | Correct | 260 ms | 22124 KB | Output is correct |
52 | Correct | 270 ms | 22124 KB | Output is correct |
53 | Correct | 106 ms | 12128 KB | Output is correct |
54 | Correct | 102 ms | 8172 KB | Output is correct |
55 | Correct | 257 ms | 22124 KB | Output is correct |
56 | Correct | 272 ms | 22124 KB | Output is correct |
57 | Correct | 107 ms | 12140 KB | Output is correct |
58 | Correct | 1 ms | 364 KB | Output is correct |
59 | Correct | 1 ms | 364 KB | Output is correct |
60 | Correct | 1 ms | 364 KB | Output is correct |
61 | Correct | 66 ms | 5868 KB | Output is correct |
62 | Correct | 260 ms | 22124 KB | Output is correct |
63 | Correct | 261 ms | 22124 KB | Output is correct |
64 | Correct | 274 ms | 22112 KB | Output is correct |
65 | Correct | 1 ms | 364 KB | Output is correct |
66 | Correct | 65 ms | 5868 KB | Output is correct |
67 | Correct | 262 ms | 22252 KB | Output is correct |
68 | Correct | 261 ms | 22124 KB | Output is correct |
69 | Correct | 273 ms | 22124 KB | Output is correct |
70 | Correct | 1 ms | 364 KB | Output is correct |
71 | Correct | 1 ms | 364 KB | Output is correct |
72 | Correct | 1 ms | 364 KB | Output is correct |
73 | Correct | 67 ms | 5868 KB | Output is correct |
74 | Correct | 261 ms | 22124 KB | Output is correct |
75 | Correct | 283 ms | 22252 KB | Output is correct |
76 | Correct | 261 ms | 22252 KB | Output is correct |
77 | Correct | 257 ms | 22124 KB | Output is correct |
78 | Correct | 1 ms | 364 KB | Output is correct |
79 | Correct | 0 ms | 364 KB | Output is correct |
80 | Correct | 7 ms | 620 KB | Output is correct |
81 | Correct | 110 ms | 8300 KB | Output is correct |
82 | Correct | 1 ms | 364 KB | Output is correct |
83 | Correct | 1 ms | 364 KB | Output is correct |
84 | Correct | 1 ms | 364 KB | Output is correct |
85 | Correct | 67 ms | 5868 KB | Output is correct |
86 | Correct | 100 ms | 8172 KB | Output is correct |
87 | Correct | 105 ms | 8172 KB | Output is correct |
88 | Correct | 99 ms | 8172 KB | Output is correct |
89 | Correct | 103 ms | 12140 KB | Output is correct |
90 | Correct | 1 ms | 256 KB | Output is correct |
91 | Correct | 1 ms | 364 KB | Output is correct |
92 | Correct | 5 ms | 620 KB | Output is correct |
93 | Correct | 103 ms | 8300 KB | Output is correct |
94 | Correct | 1 ms | 268 KB | Output is correct |
95 | Correct | 1 ms | 364 KB | Output is correct |
96 | Correct | 1 ms | 364 KB | Output is correct |
97 | Correct | 25 ms | 2284 KB | Output is correct |
98 | Correct | 98 ms | 8172 KB | Output is correct |
99 | Correct | 98 ms | 8172 KB | Output is correct |
100 | Correct | 98 ms | 8288 KB | Output is correct |
101 | Correct | 99 ms | 8172 KB | Output is correct |
102 | Correct | 98 ms | 8172 KB | Output is correct |
103 | Correct | 108 ms | 8172 KB | Output is correct |
104 | Correct | 97 ms | 8172 KB | Output is correct |
105 | Correct | 103 ms | 8172 KB | Output is correct |