Submission #1005156

# Submission time Handle Problem Language Result Execution time Memory
1005156 2024-06-22T08:10:31 Z thinknoexit Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
118 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;
			}
		}
	}
	build(ans);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 5 ms 1372 KB Output is correct
7 Correct 108 ms 24104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 5 ms 1372 KB Output is correct
7 Correct 108 ms 24104 KB Output is correct
8 Correct 0 ms 344 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 1372 KB Output is correct
13 Correct 111 ms 23972 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 372 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 61 ms 14164 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 28 ms 6216 KB Output is correct
21 Correct 108 ms 24148 KB Output is correct
22 Correct 107 ms 24144 KB Output is correct
23 Correct 118 ms 24144 KB Output is correct
24 Correct 106 ms 24004 KB Output is correct
25 Correct 55 ms 14164 KB Output is correct
26 Correct 48 ms 14164 KB Output is correct
27 Correct 117 ms 24148 KB Output is correct
28 Correct 109 ms 24144 KB Output is correct
# Verdict Execution time Memory 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 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 2 found 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 5 ms 1372 KB Output is correct
7 Correct 108 ms 24104 KB Output is correct
8 Correct 0 ms 344 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 1372 KB Output is correct
13 Correct 111 ms 23972 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 372 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 61 ms 14164 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 28 ms 6216 KB Output is correct
21 Correct 108 ms 24148 KB Output is correct
22 Correct 107 ms 24144 KB Output is correct
23 Correct 118 ms 24144 KB Output is correct
24 Correct 106 ms 24004 KB Output is correct
25 Correct 55 ms 14164 KB Output is correct
26 Correct 48 ms 14164 KB Output is correct
27 Correct 117 ms 24148 KB Output is correct
28 Correct 109 ms 24144 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 5 ms 1372 KB Output is correct
7 Correct 108 ms 24104 KB Output is correct
8 Correct 0 ms 344 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 1372 KB Output is correct
13 Correct 111 ms 23972 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 372 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 61 ms 14164 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 28 ms 6216 KB Output is correct
21 Correct 108 ms 24148 KB Output is correct
22 Correct 107 ms 24144 KB Output is correct
23 Correct 118 ms 24144 KB Output is correct
24 Correct 106 ms 24004 KB Output is correct
25 Correct 55 ms 14164 KB Output is correct
26 Correct 48 ms 14164 KB Output is correct
27 Correct 117 ms 24148 KB Output is correct
28 Correct 109 ms 24144 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -