Submission #1051366

# Submission time Handle Problem Language Result Execution time Memory
1051366 2024-08-10T05:22:24 Z Gromp15 Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
106 ms 24148 KB
#include <bits/stdc++.h>
#include "supertrees.h"
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
using namespace std;

struct dsu {
	vector<int> p, size;
	dsu(int n) : p(n), size(n, 1) {
		iota(all(p), 0);
	}
	int get(int v) {
		return v == p[v] ? v : p[v] = get(p[v]);
	}
	bool merge(int a, int b) {
		a = get(a), b = get(b);
		if (a == b) return 0;
		if (size[a] < size[b]) swap(a, b);
		size[a] += size[b], p[b] = a;
		return 1;
	}
};

int construct(std::vector<std::vector<int>> p) {
	int n = sz(p);
	dsu d(n);
	for (int i = 0; i < n; i++) for (int j = i+1; j < n; j++) if (p[i][j]) d.merge(i, j);
	for (int i = 0; i < n; i++) for (int j = i+1; j < n; j++) if (!p[i][j] && d.get(i) == d.get(j)) return 0;
	vector<vector<int>> ans(n, vector<int>(n));
	for (int i = 0; i < n; i++) if (i != d.get(i)) ans[i][d.get(i)] = ans[d.get(i)][i] = 1;
	build(ans);
	return 1;
}
# 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 1288 KB Output is correct
7 Correct 106 ms 22100 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 1288 KB Output is correct
7 Correct 106 ms 22100 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 4 ms 1368 KB Output is correct
13 Correct 98 ms 24068 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 48 ms 10240 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 24 ms 6260 KB Output is correct
21 Correct 99 ms 23924 KB Output is correct
22 Correct 95 ms 24148 KB Output is correct
23 Correct 100 ms 24068 KB Output is correct
24 Correct 105 ms 24144 KB Output is correct
25 Correct 41 ms 10068 KB Output is correct
26 Correct 39 ms 10068 KB Output is correct
27 Correct 99 ms 24144 KB Output is correct
28 Correct 96 ms 24144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 432 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 1
3 Halted 0 ms 0 KB -
# 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 1288 KB Output is correct
7 Correct 106 ms 22100 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 4 ms 1368 KB Output is correct
13 Correct 98 ms 24068 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 48 ms 10240 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 24 ms 6260 KB Output is correct
21 Correct 99 ms 23924 KB Output is correct
22 Correct 95 ms 24148 KB Output is correct
23 Correct 100 ms 24068 KB Output is correct
24 Correct 105 ms 24144 KB Output is correct
25 Correct 41 ms 10068 KB Output is correct
26 Correct 39 ms 10068 KB Output is correct
27 Correct 99 ms 24144 KB Output is correct
28 Correct 96 ms 24144 KB Output is correct
29 Correct 1 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 432 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 1288 KB Output is correct
7 Correct 106 ms 22100 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 4 ms 1368 KB Output is correct
13 Correct 98 ms 24068 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 48 ms 10240 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 24 ms 6260 KB Output is correct
21 Correct 99 ms 23924 KB Output is correct
22 Correct 95 ms 24148 KB Output is correct
23 Correct 100 ms 24068 KB Output is correct
24 Correct 105 ms 24144 KB Output is correct
25 Correct 41 ms 10068 KB Output is correct
26 Correct 39 ms 10068 KB Output is correct
27 Correct 99 ms 24144 KB Output is correct
28 Correct 96 ms 24144 KB Output is correct
29 Correct 1 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 432 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -