# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
730129 | 2023-04-25T10:06:39 Z | lucri | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 247 ms | 22152 KB |
#include "supertrees.h" #include <vector> #include <cassert> #include <cstdio> #include <cstdlib> #include <string> int t[1010]; bool e[1010],dc[1010],ca[1010]; int tata(int nod) { if(t[nod]==nod) return nod; return t[nod]=tata(t[nod]); } int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> answer; answer.resize(n); for (int i = 0; i < n; i++) { t[i]=i; dc[i]=false; e[i]=true; answer[i].resize(n); } for(int i=0;i<n;++i) { if(p[i][i]!=1) return 0; for(int j=0;j<n;++j) if(p[i][j]==1) { if(tata(i)!=tata(j)) { answer[i][j]=answer[j][i]=1; t[t[i]]=t[j]; } } else 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) { if(tata(i)==tata(j)) return 0; } } for(int i=0;i<n;++i) if(e[i]) for(int j=i+1;j<n;++j) { if(e[j]) if(tata(i)==tata(j)) { e[j]=false; for(int q=0;q<n;++q) if(p[i][q]!=p[j][q]) return 0; } } int ciclu[1010]; for(int i=0;i<n;++i) { for(int q=0;q<n;++q) ca[q]=false; ca[i]=true; if(e[i]==true&&dc[i]==false) { ciclu[0]=1; ciclu[1]=i; for(int j=0;j<n;++j) if(e[j]&&p[i][j]==2) { ciclu[++ciclu[0]]=j; ca[j]=true; } if(ciclu[0]>2) { for(int ii=1;ii<ciclu[0];++ii) { dc[ciclu[ii]]=true; answer[ciclu[ii]][ciclu[ii+1]]=answer[ciclu[ii+1]][ciclu[ii]]=1; for(int q=0;q<n;++q) { if(e[q]&&q!=ciclu[ii]) if(ca[q]==false&&p[ciclu[ii]][q]==2||ca[q]==true&&p[ciclu[ii]][q]!=2) return 0; } } answer[ciclu[ciclu[0]]][ciclu[1]]=answer[ciclu[1]][ciclu[ciclu[0]]]=1; } else if(ciclu[0]==2) return 0; } } build(answer); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 8 ms | 1108 KB | Output is correct |
7 | Correct | 242 ms | 22016 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 8 ms | 1108 KB | Output is correct |
7 | Correct | 242 ms | 22016 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1108 KB | Output is correct |
13 | Correct | 191 ms | 22152 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 708 KB | Output is correct |
17 | Correct | 97 ms | 12032 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 52 ms | 5708 KB | Output is correct |
21 | Correct | 214 ms | 21932 KB | Output is correct |
22 | Correct | 227 ms | 22012 KB | Output is correct |
23 | Correct | 208 ms | 21984 KB | Output is correct |
24 | Correct | 196 ms | 21948 KB | Output is correct |
25 | Correct | 84 ms | 12040 KB | Output is correct |
26 | Correct | 93 ms | 12044 KB | Output is correct |
27 | Correct | 207 ms | 22028 KB | Output is correct |
28 | Correct | 198 ms | 21996 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 9 ms | 1108 KB | Output is correct |
9 | Correct | 190 ms | 22128 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1108 KB | Output is correct |
13 | Correct | 195 ms | 22040 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 5 ms | 724 KB | Output is correct |
17 | Correct | 94 ms | 12036 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 48 ms | 5640 KB | Output is correct |
22 | Correct | 208 ms | 22012 KB | Output is correct |
23 | Correct | 196 ms | 21964 KB | Output is correct |
24 | Correct | 195 ms | 22148 KB | Output is correct |
25 | Correct | 102 ms | 12108 KB | Output is correct |
26 | Correct | 114 ms | 12028 KB | Output is correct |
27 | Correct | 186 ms | 22092 KB | Output is correct |
28 | Correct | 206 ms | 22012 KB | Output is correct |
29 | Correct | 92 ms | 12140 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 68 ms | 5744 KB | Output is correct |
5 | Correct | 196 ms | 22008 KB | Output is correct |
6 | Correct | 247 ms | 21964 KB | Output is correct |
7 | Correct | 199 ms | 21988 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 53 ms | 5760 KB | Output is correct |
10 | Correct | 197 ms | 22092 KB | Output is correct |
11 | Correct | 202 ms | 22028 KB | Output is correct |
12 | Correct | 195 ms | 21960 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 51 ms | 5708 KB | Output is correct |
17 | Correct | 195 ms | 22020 KB | Output is correct |
18 | Correct | 192 ms | 22008 KB | Output is correct |
19 | Correct | 206 ms | 22092 KB | Output is correct |
20 | Correct | 183 ms | 21944 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 8 ms | 1108 KB | Output is correct |
7 | Correct | 242 ms | 22016 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1108 KB | Output is correct |
13 | Correct | 191 ms | 22152 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 708 KB | Output is correct |
17 | Correct | 97 ms | 12032 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 52 ms | 5708 KB | Output is correct |
21 | Correct | 214 ms | 21932 KB | Output is correct |
22 | Correct | 227 ms | 22012 KB | Output is correct |
23 | Correct | 208 ms | 21984 KB | Output is correct |
24 | Correct | 196 ms | 21948 KB | Output is correct |
25 | Correct | 84 ms | 12040 KB | Output is correct |
26 | Correct | 93 ms | 12044 KB | Output is correct |
27 | Correct | 207 ms | 22028 KB | Output is correct |
28 | Correct | 198 ms | 21996 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 0 ms | 212 KB | Output is correct |
33 | Correct | 0 ms | 212 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Correct | 0 ms | 212 KB | Output is correct |
36 | Correct | 9 ms | 1108 KB | Output is correct |
37 | Correct | 190 ms | 22128 KB | Output is correct |
38 | Correct | 0 ms | 212 KB | Output is correct |
39 | Correct | 0 ms | 212 KB | Output is correct |
40 | Correct | 9 ms | 1108 KB | Output is correct |
41 | Correct | 195 ms | 22040 KB | Output is correct |
42 | Correct | 0 ms | 212 KB | Output is correct |
43 | Correct | 0 ms | 212 KB | Output is correct |
44 | Correct | 5 ms | 724 KB | Output is correct |
45 | Correct | 94 ms | 12036 KB | Output is correct |
46 | Correct | 1 ms | 212 KB | Output is correct |
47 | Correct | 0 ms | 212 KB | Output is correct |
48 | Correct | 0 ms | 212 KB | Output is correct |
49 | Correct | 48 ms | 5640 KB | Output is correct |
50 | Correct | 208 ms | 22012 KB | Output is correct |
51 | Correct | 196 ms | 21964 KB | Output is correct |
52 | Correct | 195 ms | 22148 KB | Output is correct |
53 | Correct | 102 ms | 12108 KB | Output is correct |
54 | Correct | 114 ms | 12028 KB | Output is correct |
55 | Correct | 186 ms | 22092 KB | Output is correct |
56 | Correct | 206 ms | 22012 KB | Output is correct |
57 | Correct | 92 ms | 12140 KB | Output is correct |
58 | Correct | 0 ms | 212 KB | Output is correct |
59 | Correct | 1 ms | 212 KB | Output is correct |
60 | Correct | 4 ms | 724 KB | Output is correct |
61 | Correct | 99 ms | 12128 KB | Output is correct |
62 | Correct | 0 ms | 212 KB | Output is correct |
63 | Correct | 0 ms | 212 KB | Output is correct |
64 | Correct | 0 ms | 212 KB | Output is correct |
65 | Correct | 52 ms | 5764 KB | Output is correct |
66 | Correct | 87 ms | 12028 KB | Output is correct |
67 | Correct | 83 ms | 12108 KB | Output is correct |
68 | Correct | 105 ms | 12108 KB | Output is correct |
69 | Correct | 94 ms | 12028 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 8 ms | 1108 KB | Output is correct |
7 | Correct | 242 ms | 22016 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1108 KB | Output is correct |
13 | Correct | 191 ms | 22152 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 708 KB | Output is correct |
17 | Correct | 97 ms | 12032 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 52 ms | 5708 KB | Output is correct |
21 | Correct | 214 ms | 21932 KB | Output is correct |
22 | Correct | 227 ms | 22012 KB | Output is correct |
23 | Correct | 208 ms | 21984 KB | Output is correct |
24 | Correct | 196 ms | 21948 KB | Output is correct |
25 | Correct | 84 ms | 12040 KB | Output is correct |
26 | Correct | 93 ms | 12044 KB | Output is correct |
27 | Correct | 207 ms | 22028 KB | Output is correct |
28 | Correct | 198 ms | 21996 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 0 ms | 212 KB | Output is correct |
33 | Correct | 0 ms | 212 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Correct | 0 ms | 212 KB | Output is correct |
36 | Correct | 9 ms | 1108 KB | Output is correct |
37 | Correct | 190 ms | 22128 KB | Output is correct |
38 | Correct | 0 ms | 212 KB | Output is correct |
39 | Correct | 0 ms | 212 KB | Output is correct |
40 | Correct | 9 ms | 1108 KB | Output is correct |
41 | Correct | 195 ms | 22040 KB | Output is correct |
42 | Correct | 0 ms | 212 KB | Output is correct |
43 | Correct | 0 ms | 212 KB | Output is correct |
44 | Correct | 5 ms | 724 KB | Output is correct |
45 | Correct | 94 ms | 12036 KB | Output is correct |
46 | Correct | 1 ms | 212 KB | Output is correct |
47 | Correct | 0 ms | 212 KB | Output is correct |
48 | Correct | 0 ms | 212 KB | Output is correct |
49 | Correct | 48 ms | 5640 KB | Output is correct |
50 | Correct | 208 ms | 22012 KB | Output is correct |
51 | Correct | 196 ms | 21964 KB | Output is correct |
52 | Correct | 195 ms | 22148 KB | Output is correct |
53 | Correct | 102 ms | 12108 KB | Output is correct |
54 | Correct | 114 ms | 12028 KB | Output is correct |
55 | Correct | 186 ms | 22092 KB | Output is correct |
56 | Correct | 206 ms | 22012 KB | Output is correct |
57 | Correct | 92 ms | 12140 KB | Output is correct |
58 | Correct | 0 ms | 212 KB | Output is correct |
59 | Correct | 0 ms | 212 KB | Output is correct |
60 | Correct | 1 ms | 212 KB | Output is correct |
61 | Correct | 68 ms | 5744 KB | Output is correct |
62 | Correct | 196 ms | 22008 KB | Output is correct |
63 | Correct | 247 ms | 21964 KB | Output is correct |
64 | Correct | 199 ms | 21988 KB | Output is correct |
65 | Correct | 1 ms | 212 KB | Output is correct |
66 | Correct | 53 ms | 5760 KB | Output is correct |
67 | Correct | 197 ms | 22092 KB | Output is correct |
68 | Correct | 202 ms | 22028 KB | Output is correct |
69 | Correct | 195 ms | 21960 KB | Output is correct |
70 | Correct | 0 ms | 212 KB | Output is correct |
71 | Correct | 0 ms | 212 KB | Output is correct |
72 | Correct | 0 ms | 212 KB | Output is correct |
73 | Correct | 51 ms | 5708 KB | Output is correct |
74 | Correct | 195 ms | 22020 KB | Output is correct |
75 | Correct | 192 ms | 22008 KB | Output is correct |
76 | Correct | 206 ms | 22092 KB | Output is correct |
77 | Correct | 183 ms | 21944 KB | Output is correct |
78 | Correct | 0 ms | 212 KB | Output is correct |
79 | Correct | 1 ms | 212 KB | Output is correct |
80 | Correct | 4 ms | 724 KB | Output is correct |
81 | Correct | 99 ms | 12128 KB | Output is correct |
82 | Correct | 0 ms | 212 KB | Output is correct |
83 | Correct | 0 ms | 212 KB | Output is correct |
84 | Correct | 0 ms | 212 KB | Output is correct |
85 | Correct | 52 ms | 5764 KB | Output is correct |
86 | Correct | 87 ms | 12028 KB | Output is correct |
87 | Correct | 83 ms | 12108 KB | Output is correct |
88 | Correct | 105 ms | 12108 KB | Output is correct |
89 | Correct | 94 ms | 12028 KB | Output is correct |
90 | Correct | 1 ms | 212 KB | Output is correct |
91 | Correct | 0 ms | 212 KB | Output is correct |
92 | Correct | 4 ms | 724 KB | Output is correct |
93 | Correct | 94 ms | 12028 KB | Output is correct |
94 | Correct | 0 ms | 212 KB | Output is correct |
95 | Correct | 0 ms | 212 KB | Output is correct |
96 | Correct | 0 ms | 212 KB | Output is correct |
97 | Correct | 21 ms | 3700 KB | Output is correct |
98 | Correct | 92 ms | 14064 KB | Output is correct |
99 | Correct | 90 ms | 14068 KB | Output is correct |
100 | Correct | 81 ms | 14084 KB | Output is correct |
101 | Correct | 87 ms | 13996 KB | Output is correct |
102 | Correct | 85 ms | 14064 KB | Output is correct |
103 | Correct | 103 ms | 14080 KB | Output is correct |
104 | Correct | 82 ms | 14080 KB | Output is correct |
105 | Correct | 84 ms | 14072 KB | Output is correct |