답안 #794928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
794928 2023-07-27T04:09:54 Z boyliguanhan 슈퍼트리 잇기 (IOI20_supertrees) C++17
100 / 100
171 ms 28028 KB
#include "supertrees.h" 
#include <bits/stdc++.h>
using namespace std;
 
int comp[1010], tree[1010], comps, sz[1010], roots[1010][1010];
int construct(std::vector<std::vector<int>> p) {
    for(auto i:p)
        for(auto j: i)
            if(j>2)
                return 0;
    int n = p.size();
	std::vector<std::vector<int>> answer(n,vector<int>(n,0));
    for(int i = 0; i < n; i++) {
        bool determined=0;
        bitset<1024>notree;
        bitset<1024>notcomp;
        for(int j = 0; j < i; j++) {
            if(determined) {
                if(!p[i][j]){
                    if(comp[i]==comp[j]) 
                        return 0;
               } else if(comp[i]!=comp[j])
                    return 0;
                else if(p[i][j]==1&&tree[i]!=tree[j])
                    return 0;
            } else {
                if(!p[i][j])
                    notcomp[comp[j]]=1;
                else if(p[i][j]-1) {
                    if(notcomp[comp[j]]) return 0;
                    notcomp.reset();
                    notcomp.flip();
                    notcomp[comp[j]] = 0;
                    notree[tree[j]] = 1;
                    comp[i] = comp[j];
                } else {
                    if(notcomp[comp[j]]) return 0;
                    if(notree[tree[j]]) return 0;
                    answer[i][j] = answer[j][i] = 1;
                    tree[i] = tree[j];
                    comp[i] = comp[j];
                    notcomp.reset();
                    notcomp.flip();
                    notcomp[comp[j]] = 0;
                    notree.reset();
                    notree.flip();
                    notree[tree[j]] = 0;
                    determined = 1;
                }
            }
        }
        if(!comp[i]) {
            comp[i] = ++comps;
            roots[comp[i]][1] = i;
            sz[comps] = tree[i] = 1;
        } else if(!tree[i]) {
            tree[i] = ++sz[comp[i]];
            roots[comp[i]][sz[comp[i]]] = i;
        }
        if(notcomp[comp[i]]||notree[tree[i]]) return 0;
    } 
    for(int i = 1; i <= comps; i++) {
        if(sz[i]==1) continue;
        if(sz[i]==2) return 0;
        for(int j = 1; j < sz[i]; j++) {
            answer[roots[i][j]][roots[i][j+1]] = answer[roots[i][j+1]][roots[i][j]] = 1;
        }
        answer[roots[i][1]][roots[i][sz[i]]] = answer[roots[i][sz[i]]][roots[i][1]] = 1;
    }
	build(answer);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 1296 KB Output is correct
7 Correct 149 ms 23932 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 308 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 1296 KB Output is correct
7 Correct 149 ms 23932 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 8 ms 2004 KB Output is correct
13 Correct 171 ms 27908 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 65 ms 13868 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 40 ms 6548 KB Output is correct
21 Correct 154 ms 23936 KB Output is correct
22 Correct 163 ms 25608 KB Output is correct
23 Correct 161 ms 24004 KB Output is correct
24 Correct 171 ms 27712 KB Output is correct
25 Correct 76 ms 13824 KB Output is correct
26 Correct 67 ms 14900 KB Output is correct
27 Correct 155 ms 23932 KB Output is correct
28 Correct 155 ms 27784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 9 ms 2084 KB Output is correct
9 Correct 157 ms 28028 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1184 KB Output is correct
13 Correct 161 ms 23928 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 3 ms 828 KB Output is correct
17 Correct 65 ms 13796 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 312 KB Output is correct
20 Correct 0 ms 312 KB Output is correct
21 Correct 40 ms 6496 KB Output is correct
22 Correct 155 ms 24012 KB Output is correct
23 Correct 152 ms 24752 KB Output is correct
24 Correct 164 ms 24072 KB Output is correct
25 Correct 65 ms 17548 KB Output is correct
26 Correct 68 ms 13852 KB Output is correct
27 Correct 158 ms 24712 KB Output is correct
28 Correct 164 ms 23980 KB Output is correct
29 Correct 65 ms 17492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 38 ms 6472 KB Output is correct
5 Correct 156 ms 24088 KB Output is correct
6 Correct 153 ms 25484 KB Output is correct
7 Correct 156 ms 23928 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 41 ms 6476 KB Output is correct
10 Correct 157 ms 23944 KB Output is correct
11 Correct 152 ms 24780 KB Output is correct
12 Correct 168 ms 23932 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 304 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 39 ms 6556 KB Output is correct
17 Correct 154 ms 24076 KB Output is correct
18 Correct 155 ms 24060 KB Output is correct
19 Correct 155 ms 24092 KB Output is correct
20 Correct 157 ms 27684 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 308 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 1296 KB Output is correct
7 Correct 149 ms 23932 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 8 ms 2004 KB Output is correct
13 Correct 171 ms 27908 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 65 ms 13868 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 40 ms 6548 KB Output is correct
21 Correct 154 ms 23936 KB Output is correct
22 Correct 163 ms 25608 KB Output is correct
23 Correct 161 ms 24004 KB Output is correct
24 Correct 171 ms 27712 KB Output is correct
25 Correct 76 ms 13824 KB Output is correct
26 Correct 67 ms 14900 KB Output is correct
27 Correct 155 ms 23932 KB Output is correct
28 Correct 155 ms 27784 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 312 KB Output is correct
36 Correct 9 ms 2084 KB Output is correct
37 Correct 157 ms 28028 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 7 ms 1184 KB Output is correct
41 Correct 161 ms 23928 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 3 ms 828 KB Output is correct
45 Correct 65 ms 13796 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 312 KB Output is correct
48 Correct 0 ms 312 KB Output is correct
49 Correct 40 ms 6496 KB Output is correct
50 Correct 155 ms 24012 KB Output is correct
51 Correct 152 ms 24752 KB Output is correct
52 Correct 164 ms 24072 KB Output is correct
53 Correct 65 ms 17548 KB Output is correct
54 Correct 68 ms 13852 KB Output is correct
55 Correct 158 ms 24712 KB Output is correct
56 Correct 164 ms 23980 KB Output is correct
57 Correct 65 ms 17492 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 312 KB Output is correct
60 Correct 3 ms 852 KB Output is correct
61 Correct 66 ms 13724 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 0 ms 212 KB Output is correct
64 Correct 0 ms 340 KB Output is correct
65 Correct 39 ms 6524 KB Output is correct
66 Correct 63 ms 13532 KB Output is correct
67 Correct 65 ms 13568 KB Output is correct
68 Correct 68 ms 13652 KB Output is correct
69 Correct 65 ms 17312 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 308 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 1296 KB Output is correct
7 Correct 149 ms 23932 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 8 ms 2004 KB Output is correct
13 Correct 171 ms 27908 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 65 ms 13868 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 40 ms 6548 KB Output is correct
21 Correct 154 ms 23936 KB Output is correct
22 Correct 163 ms 25608 KB Output is correct
23 Correct 161 ms 24004 KB Output is correct
24 Correct 171 ms 27712 KB Output is correct
25 Correct 76 ms 13824 KB Output is correct
26 Correct 67 ms 14900 KB Output is correct
27 Correct 155 ms 23932 KB Output is correct
28 Correct 155 ms 27784 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 312 KB Output is correct
36 Correct 9 ms 2084 KB Output is correct
37 Correct 157 ms 28028 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 7 ms 1184 KB Output is correct
41 Correct 161 ms 23928 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 3 ms 828 KB Output is correct
45 Correct 65 ms 13796 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 312 KB Output is correct
48 Correct 0 ms 312 KB Output is correct
49 Correct 40 ms 6496 KB Output is correct
50 Correct 155 ms 24012 KB Output is correct
51 Correct 152 ms 24752 KB Output is correct
52 Correct 164 ms 24072 KB Output is correct
53 Correct 65 ms 17548 KB Output is correct
54 Correct 68 ms 13852 KB Output is correct
55 Correct 158 ms 24712 KB Output is correct
56 Correct 164 ms 23980 KB Output is correct
57 Correct 65 ms 17492 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 0 ms 212 KB Output is correct
61 Correct 38 ms 6472 KB Output is correct
62 Correct 156 ms 24088 KB Output is correct
63 Correct 153 ms 25484 KB Output is correct
64 Correct 156 ms 23928 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 41 ms 6476 KB Output is correct
67 Correct 157 ms 23944 KB Output is correct
68 Correct 152 ms 24780 KB Output is correct
69 Correct 168 ms 23932 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Correct 0 ms 304 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 39 ms 6556 KB Output is correct
74 Correct 154 ms 24076 KB Output is correct
75 Correct 155 ms 24060 KB Output is correct
76 Correct 155 ms 24092 KB Output is correct
77 Correct 157 ms 27684 KB Output is correct
78 Correct 1 ms 212 KB Output is correct
79 Correct 1 ms 312 KB Output is correct
80 Correct 3 ms 852 KB Output is correct
81 Correct 66 ms 13724 KB Output is correct
82 Correct 1 ms 212 KB Output is correct
83 Correct 0 ms 212 KB Output is correct
84 Correct 0 ms 340 KB Output is correct
85 Correct 39 ms 6524 KB Output is correct
86 Correct 63 ms 13532 KB Output is correct
87 Correct 65 ms 13568 KB Output is correct
88 Correct 68 ms 13652 KB Output is correct
89 Correct 65 ms 17312 KB Output is correct
90 Correct 1 ms 212 KB Output is correct
91 Correct 0 ms 312 KB Output is correct
92 Correct 3 ms 596 KB Output is correct
93 Correct 69 ms 9536 KB Output is correct
94 Correct 1 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 16 ms 2684 KB Output is correct
98 Correct 61 ms 9528 KB Output is correct
99 Correct 62 ms 9548 KB Output is correct
100 Correct 62 ms 9576 KB Output is correct
101 Correct 64 ms 9508 KB Output is correct
102 Correct 60 ms 9664 KB Output is correct
103 Correct 59 ms 9600 KB Output is correct
104 Correct 59 ms 9508 KB Output is correct
105 Correct 63 ms 9500 KB Output is correct