답안 #565752

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
565752 2022-05-21T10:17:39 Z sidon 슈퍼트리 잇기 (IOI20_supertrees) C++17
100 / 100
194 ms 22548 KB
#include "supertrees.h"
#include "bits/stdc++.h"
using namespace std;

int construct(vector<vector<int>> p) {
	int n = size(p);
	vector<vector<int>> g(n, vector<int> (n));
	bool vis[n] {};

	for(int r = 0; r < n; ++r) if(!vis[r]) {
		if(*max_element(begin(p[r]), end(p[r])) > 2) return 0;
		vector<int> c;
		vector<vector<int>> s;

		for(int i = r; i < n; ++i) if(!vis[i] && p[r][i]) {
			vis[i] = 1;
			c.push_back(i);
		}

		for(int i : c) {
			for(int j : c) if(!p[i][j]) return 0;

			if(vis[i]) {
				s.push_back({});
				for(int j : c) if(p[i][j] < 2 && vis[j]) {
					vis[j] = 0;
					s.back().push_back(j);
				} 
			}
		}
		for(auto &x : s) {
			for(auto &y : s) for(int i : x) for(int j : y)
				if((x[0] != y[0]) != (p[i][j] > 1)) return 0;

			for(int i = 1; i < int(size(x)); ++i)
				g[x[i-1]][x[i]] = g[x[i]][x[i-1]] = 1;
		}
		if(size(s) == 2) return 0;
		for(int i = 0; i < int(size(s)); ++i) {
			int u = s[i][0], v = s[(i+1) % size(s)][0];
			if(u != v) g[u][v] = g[v][u] = 1;
		}
		for(int i : c) for(int j = 0; j < n; ++j)
			if(vis[j] && p[i][j]) return 0;

		for(int i : c) vis[i] = 1;
	}

	return build(g), 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1200 KB Output is correct
7 Correct 171 ms 22320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1200 KB Output is correct
7 Correct 171 ms 22320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 7 ms 1172 KB Output is correct
13 Correct 177 ms 22432 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 74 ms 12564 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 43 ms 6188 KB Output is correct
21 Correct 167 ms 22480 KB Output is correct
22 Correct 167 ms 22480 KB Output is correct
23 Correct 183 ms 22540 KB Output is correct
24 Correct 181 ms 22548 KB Output is correct
25 Correct 72 ms 12416 KB Output is correct
26 Correct 83 ms 12352 KB Output is correct
27 Correct 181 ms 22096 KB Output is correct
28 Correct 169 ms 22020 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 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 7 ms 1192 KB Output is correct
9 Correct 169 ms 22064 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 8 ms 1108 KB Output is correct
13 Correct 177 ms 22208 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 74 ms 12184 KB Output is correct
18 Correct 0 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 44 ms 5764 KB Output is correct
22 Correct 167 ms 22176 KB Output is correct
23 Correct 177 ms 22244 KB Output is correct
24 Correct 173 ms 22172 KB Output is correct
25 Correct 71 ms 12300 KB Output is correct
26 Correct 69 ms 12176 KB Output is correct
27 Correct 194 ms 22088 KB Output is correct
28 Correct 181 ms 22088 KB Output is correct
29 Correct 68 ms 12244 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 42 ms 5764 KB Output is correct
5 Correct 181 ms 21988 KB Output is correct
6 Correct 165 ms 22056 KB Output is correct
7 Correct 176 ms 22020 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 45 ms 5760 KB Output is correct
10 Correct 167 ms 22028 KB Output is correct
11 Correct 173 ms 21964 KB Output is correct
12 Correct 170 ms 22020 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 42 ms 5660 KB Output is correct
17 Correct 165 ms 21964 KB Output is correct
18 Correct 167 ms 22068 KB Output is correct
19 Correct 164 ms 22032 KB Output is correct
20 Correct 166 ms 21964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1200 KB Output is correct
7 Correct 171 ms 22320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 7 ms 1172 KB Output is correct
13 Correct 177 ms 22432 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 74 ms 12564 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 43 ms 6188 KB Output is correct
21 Correct 167 ms 22480 KB Output is correct
22 Correct 167 ms 22480 KB Output is correct
23 Correct 183 ms 22540 KB Output is correct
24 Correct 181 ms 22548 KB Output is correct
25 Correct 72 ms 12416 KB Output is correct
26 Correct 83 ms 12352 KB Output is correct
27 Correct 181 ms 22096 KB Output is correct
28 Correct 169 ms 22020 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 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 7 ms 1192 KB Output is correct
37 Correct 169 ms 22064 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 8 ms 1108 KB Output is correct
41 Correct 177 ms 22208 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 3 ms 724 KB Output is correct
45 Correct 74 ms 12184 KB Output is correct
46 Correct 0 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 44 ms 5764 KB Output is correct
50 Correct 167 ms 22176 KB Output is correct
51 Correct 177 ms 22244 KB Output is correct
52 Correct 173 ms 22172 KB Output is correct
53 Correct 71 ms 12300 KB Output is correct
54 Correct 69 ms 12176 KB Output is correct
55 Correct 194 ms 22088 KB Output is correct
56 Correct 181 ms 22088 KB Output is correct
57 Correct 68 ms 12244 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 5 ms 724 KB Output is correct
61 Correct 78 ms 12160 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 45 ms 5732 KB Output is correct
66 Correct 74 ms 12184 KB Output is correct
67 Correct 72 ms 12268 KB Output is correct
68 Correct 71 ms 12232 KB Output is correct
69 Correct 76 ms 12164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1200 KB Output is correct
7 Correct 171 ms 22320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 7 ms 1172 KB Output is correct
13 Correct 177 ms 22432 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 74 ms 12564 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 43 ms 6188 KB Output is correct
21 Correct 167 ms 22480 KB Output is correct
22 Correct 167 ms 22480 KB Output is correct
23 Correct 183 ms 22540 KB Output is correct
24 Correct 181 ms 22548 KB Output is correct
25 Correct 72 ms 12416 KB Output is correct
26 Correct 83 ms 12352 KB Output is correct
27 Correct 181 ms 22096 KB Output is correct
28 Correct 169 ms 22020 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 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 7 ms 1192 KB Output is correct
37 Correct 169 ms 22064 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 8 ms 1108 KB Output is correct
41 Correct 177 ms 22208 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 3 ms 724 KB Output is correct
45 Correct 74 ms 12184 KB Output is correct
46 Correct 0 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 44 ms 5764 KB Output is correct
50 Correct 167 ms 22176 KB Output is correct
51 Correct 177 ms 22244 KB Output is correct
52 Correct 173 ms 22172 KB Output is correct
53 Correct 71 ms 12300 KB Output is correct
54 Correct 69 ms 12176 KB Output is correct
55 Correct 194 ms 22088 KB Output is correct
56 Correct 181 ms 22088 KB Output is correct
57 Correct 68 ms 12244 KB Output is correct
58 Correct 0 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 42 ms 5764 KB Output is correct
62 Correct 181 ms 21988 KB Output is correct
63 Correct 165 ms 22056 KB Output is correct
64 Correct 176 ms 22020 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 45 ms 5760 KB Output is correct
67 Correct 167 ms 22028 KB Output is correct
68 Correct 173 ms 21964 KB Output is correct
69 Correct 170 ms 22020 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 0 ms 212 KB Output is correct
73 Correct 42 ms 5660 KB Output is correct
74 Correct 165 ms 21964 KB Output is correct
75 Correct 167 ms 22068 KB Output is correct
76 Correct 164 ms 22032 KB Output is correct
77 Correct 166 ms 21964 KB Output is correct
78 Correct 0 ms 212 KB Output is correct
79 Correct 0 ms 212 KB Output is correct
80 Correct 5 ms 724 KB Output is correct
81 Correct 78 ms 12160 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 45 ms 5732 KB Output is correct
86 Correct 74 ms 12184 KB Output is correct
87 Correct 72 ms 12268 KB Output is correct
88 Correct 71 ms 12232 KB Output is correct
89 Correct 76 ms 12164 KB Output is correct
90 Correct 0 ms 212 KB Output is correct
91 Correct 0 ms 212 KB Output is correct
92 Correct 4 ms 716 KB Output is correct
93 Correct 74 ms 12168 KB Output is correct
94 Correct 0 ms 212 KB Output is correct
95 Correct 1 ms 340 KB Output is correct
96 Correct 1 ms 300 KB Output is correct
97 Correct 20 ms 3688 KB Output is correct
98 Correct 74 ms 14076 KB Output is correct
99 Correct 81 ms 14080 KB Output is correct
100 Correct 78 ms 14076 KB Output is correct
101 Correct 71 ms 14076 KB Output is correct
102 Correct 76 ms 14076 KB Output is correct
103 Correct 73 ms 14072 KB Output is correct
104 Correct 105 ms 14072 KB Output is correct
105 Correct 99 ms 14068 KB Output is correct