답안 #1005160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005160 2024-06-22T08:13:20 Z thinknoexit 슈퍼트리 잇기 (IOI20_supertrees) C++17
40 / 100
115 ms 24148 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1010;
int p[N];
vector<int> g[N];
int fr(int i) {
	return p[i] == i ? i : p[i] = fr(p[i]);
}
int construct(vector<vector<int>> B) {
	int n = B.size();
	for (int i = 0;i < n;i++) p[i] = i;
	vector<vector<int>> ans(n, vector<int>(n, 0));
	for (int i = 0;i < n;i++) {
		for (int j = i + 1;j < n;j++) {
			if (B[i][j]) {
				p[fr(i)] = fr(j);
			}
		}
	}
	for (int i = 0;i < n;i++) {
		g[fr(i)].push_back(i);
	}
	for (int G = 0;G < n;G++) {
		if (g[G].empty() || (int)g[G].size() == 1) continue;
		auto& v = g[G];
		int m = v.size();
		int cnt = 0;
		for (int i = 0;i < m;i++) {
			for (int j = i + 1;j < m;j++) {
				if (B[v[i]][v[j]] == 0) return 0;
				cnt += (B[v[i]][v[j]] == 1);
			}
		}
		if (cnt == m * (m - 1) / 2) {
			for (int i = 1;i < m;i++) {
				ans[v[0]][v[i]] = ans[v[i]][v[0]] = 1;
			}
		}
		else {
			if (m == 2) return 0;
			for (int i = 0;i < m;i++) {
				ans[v[i]][v[(i + 1) % m]] = ans[v[(i + 1) % m]][v[i]] = 1;
			}
		}
	}
	build(ans);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1116 KB Output is correct
7 Correct 99 ms 22116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1116 KB Output is correct
7 Correct 99 ms 22116 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1324 KB Output is correct
13 Correct 112 ms 22068 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 51 ms 12080 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 24 ms 5916 KB Output is correct
21 Correct 111 ms 22100 KB Output is correct
22 Correct 104 ms 22132 KB Output is correct
23 Correct 103 ms 22100 KB Output is correct
24 Correct 95 ms 22100 KB Output is correct
25 Correct 52 ms 12112 KB Output is correct
26 Correct 43 ms 12116 KB Output is correct
27 Correct 102 ms 22068 KB Output is correct
28 Correct 112 ms 22100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 4 ms 1372 KB Output is correct
9 Correct 100 ms 24100 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1372 KB Output is correct
13 Correct 115 ms 24100 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 58 ms 14240 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 26 ms 6236 KB Output is correct
22 Correct 112 ms 24148 KB Output is correct
23 Correct 113 ms 24148 KB Output is correct
24 Correct 110 ms 24148 KB Output is correct
25 Correct 55 ms 14116 KB Output is correct
26 Correct 47 ms 14160 KB Output is correct
27 Correct 102 ms 24060 KB Output is correct
28 Correct 101 ms 24148 KB Output is correct
29 Correct 47 ms 14164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 25 ms 5716 KB Output is correct
5 Correct 111 ms 22052 KB Output is correct
6 Correct 105 ms 22096 KB Output is correct
7 Correct 103 ms 22064 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 24 ms 5724 KB Output is correct
10 Correct 99 ms 22056 KB Output is correct
11 Correct 98 ms 22100 KB Output is correct
12 Correct 114 ms 22216 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Too many ways to get from 0 to 4, should be 1 found no less than 2
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1116 KB Output is correct
7 Correct 99 ms 22116 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1324 KB Output is correct
13 Correct 112 ms 22068 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 51 ms 12080 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 24 ms 5916 KB Output is correct
21 Correct 111 ms 22100 KB Output is correct
22 Correct 104 ms 22132 KB Output is correct
23 Correct 103 ms 22100 KB Output is correct
24 Correct 95 ms 22100 KB Output is correct
25 Correct 52 ms 12112 KB Output is correct
26 Correct 43 ms 12116 KB Output is correct
27 Correct 102 ms 22068 KB Output is correct
28 Correct 112 ms 22100 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 4 ms 1372 KB Output is correct
37 Correct 100 ms 24100 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 5 ms 1372 KB Output is correct
41 Correct 115 ms 24100 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 3 ms 860 KB Output is correct
45 Correct 58 ms 14240 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 26 ms 6236 KB Output is correct
50 Correct 112 ms 24148 KB Output is correct
51 Correct 113 ms 24148 KB Output is correct
52 Correct 110 ms 24148 KB Output is correct
53 Correct 55 ms 14116 KB Output is correct
54 Correct 47 ms 14160 KB Output is correct
55 Correct 102 ms 24060 KB Output is correct
56 Correct 101 ms 24148 KB Output is correct
57 Correct 47 ms 14164 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 2 ms 964 KB Output is correct
61 Correct 55 ms 14168 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Incorrect 27 ms 6232 KB Too many ways to get from 1 to 269, should be 1 found no less than 2
66 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1116 KB Output is correct
7 Correct 99 ms 22116 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1324 KB Output is correct
13 Correct 112 ms 22068 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 51 ms 12080 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 24 ms 5916 KB Output is correct
21 Correct 111 ms 22100 KB Output is correct
22 Correct 104 ms 22132 KB Output is correct
23 Correct 103 ms 22100 KB Output is correct
24 Correct 95 ms 22100 KB Output is correct
25 Correct 52 ms 12112 KB Output is correct
26 Correct 43 ms 12116 KB Output is correct
27 Correct 102 ms 22068 KB Output is correct
28 Correct 112 ms 22100 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 4 ms 1372 KB Output is correct
37 Correct 100 ms 24100 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 5 ms 1372 KB Output is correct
41 Correct 115 ms 24100 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 3 ms 860 KB Output is correct
45 Correct 58 ms 14240 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 26 ms 6236 KB Output is correct
50 Correct 112 ms 24148 KB Output is correct
51 Correct 113 ms 24148 KB Output is correct
52 Correct 110 ms 24148 KB Output is correct
53 Correct 55 ms 14116 KB Output is correct
54 Correct 47 ms 14160 KB Output is correct
55 Correct 102 ms 24060 KB Output is correct
56 Correct 101 ms 24148 KB Output is correct
57 Correct 47 ms 14164 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 25 ms 5716 KB Output is correct
62 Correct 111 ms 22052 KB Output is correct
63 Correct 105 ms 22096 KB Output is correct
64 Correct 103 ms 22064 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 24 ms 5724 KB Output is correct
67 Correct 99 ms 22056 KB Output is correct
68 Correct 98 ms 22100 KB Output is correct
69 Correct 114 ms 22216 KB Output is correct
70 Correct 0 ms 348 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Incorrect 0 ms 348 KB Too many ways to get from 0 to 4, should be 1 found no less than 2
73 Halted 0 ms 0 KB -