Submission #832260

# Submission time Handle Problem Language Result Execution time Memory
832260 2023-08-21T08:03:25 Z Johann Connecting Supertrees (IOI20_supertrees) C++14
21 / 100
173 ms 23976 KB
#include "supertrees.h"
#include "bits/stdc++.h"
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

int construct(std::vector<std::vector<int>> p)
{
	int N = p.size();
	vi comp(N, -1);

	vvi ans(N, vi(N, 0));
	for (int v = 0; v < N; ++v)
	{
		if (comp[v] == -1)
		{
			vvi c(4);
			comp[v] = v;
			for (int u = 0; u < N; ++u)
			{
				if (p[v][u] == 0 || u == v)
					continue;
				if (comp[u] != -1)
					return 0;
				comp[u] = v;
				c[p[v][u]].push_back(u);
			}

			if (sz(c[2]) && sz(c[3]))
				return 0;

			for (int u : c[1])
			{
				ans[v][u] = ans[u][v] = 1;
				for (int w = 0; w < N; ++w)
					if (comp[w] != comp[u] && p[u][w] > 0)
						return 0;
				for (int w : c[1])
					if (p[u][w] != 1)
						return 0;
				for (int w : c[2])
					if (p[u][w] != 2)
						return 0;
				for (int w : c[3])
					if (p[u][w] != 3)
						return 0;
			}
		}
	}

	build(ans);
	return 1;
}
# Verdict Execution time Memory 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 6 ms 1108 KB Output is correct
7 Correct 173 ms 22032 KB Output is correct
# Verdict Execution time Memory 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 6 ms 1108 KB Output is correct
7 Correct 173 ms 22032 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 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 1180 KB Output is correct
13 Correct 156 ms 22020 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 67 ms 12040 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 45 ms 5824 KB Output is correct
21 Correct 154 ms 21964 KB Output is correct
22 Correct 156 ms 22024 KB Output is correct
23 Correct 162 ms 22020 KB Output is correct
24 Correct 158 ms 21952 KB Output is correct
25 Correct 63 ms 12032 KB Output is correct
26 Correct 69 ms 14028 KB Output is correct
27 Correct 157 ms 23956 KB Output is correct
28 Correct 159 ms 23976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 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 212 KB Output is correct
2 Incorrect 0 ms 212 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 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 6 ms 1108 KB Output is correct
7 Correct 173 ms 22032 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 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 1180 KB Output is correct
13 Correct 156 ms 22020 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 67 ms 12040 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 45 ms 5824 KB Output is correct
21 Correct 154 ms 21964 KB Output is correct
22 Correct 156 ms 22024 KB Output is correct
23 Correct 162 ms 22020 KB Output is correct
24 Correct 158 ms 21952 KB Output is correct
25 Correct 63 ms 12032 KB Output is correct
26 Correct 69 ms 14028 KB Output is correct
27 Correct 157 ms 23956 KB Output is correct
28 Correct 159 ms 23976 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 1 ms 212 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 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 6 ms 1108 KB Output is correct
7 Correct 173 ms 22032 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 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 1180 KB Output is correct
13 Correct 156 ms 22020 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 67 ms 12040 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 45 ms 5824 KB Output is correct
21 Correct 154 ms 21964 KB Output is correct
22 Correct 156 ms 22024 KB Output is correct
23 Correct 162 ms 22020 KB Output is correct
24 Correct 158 ms 21952 KB Output is correct
25 Correct 63 ms 12032 KB Output is correct
26 Correct 69 ms 14028 KB Output is correct
27 Correct 157 ms 23956 KB Output is correct
28 Correct 159 ms 23976 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 1 ms 212 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -