Submission #792043

# Submission time Handle Problem Language Result Execution time Memory
792043 2023-07-24T14:14:52 Z mousebeaver Connecting Supertrees (IOI20_supertrees) C++14
21 / 100
180 ms 24024 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;

int construct(vector<vector<int>> p) 
{
	bool sub1 = true;
	int n = p.size();

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(p[i][j] != 1)
			{
				sub1 = false;
			}
		}
	}
	
	if(sub1)
	{
		vector<vector<int>> adjmatrix(n, vector<int> (n, 0));
		for(int i = 0; i < n-1; i++)
		{
			adjmatrix[i][i+1] = 1;
			adjmatrix[i+1][i] = 1;
		}
		build(adjmatrix);
		return 1;
	}

	//sub2
	vector<vector<int>> adjmatrix(n, vector<int> (n, 0));
	vector<bool> used(n, false);
	for(int i = 0; i < n; i++)
	{
		if(!used[i])
		{
			vector<int> nodes(0);
			for(int j = 0; j < n; j++)
			{
				if(p[i][j] == 1)
				{
					nodes.push_back(j);
					used[j] = true;
				}
			}

			for(int i : nodes)
			{
				if(count(p[i].begin(), p[i].end(), 1) != (int) nodes.size())
				{
					return 0;
				}
				for(int j : nodes)
				{
					if(p[i][j] != 1)
					{
						return 0;
					}
				}
			}

			for(int i = 0; i < (int) nodes.size()-1; i++)
			{
				adjmatrix[nodes[i]][nodes[i+1]] = 1;
				adjmatrix[nodes[i+1]][nodes[i]] = 1;
			}
		}
	}
	build(adjmatrix);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 9 ms 1100 KB Output is correct
7 Correct 180 ms 22024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 9 ms 1100 KB Output is correct
7 Correct 180 ms 22024 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 300 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 1256 KB Output is correct
13 Correct 155 ms 23936 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 82 ms 14072 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 38 ms 6260 KB Output is correct
21 Correct 154 ms 24024 KB Output is correct
22 Correct 167 ms 23976 KB Output is correct
23 Correct 153 ms 23936 KB Output is correct
24 Correct 170 ms 23968 KB Output is correct
25 Correct 62 ms 14068 KB Output is correct
26 Correct 61 ms 14064 KB Output is correct
27 Correct 153 ms 23976 KB Output is correct
28 Correct 157 ms 23964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 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 1 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 1 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 9 ms 1100 KB Output is correct
7 Correct 180 ms 22024 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 300 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 1256 KB Output is correct
13 Correct 155 ms 23936 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 82 ms 14072 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 38 ms 6260 KB Output is correct
21 Correct 154 ms 24024 KB Output is correct
22 Correct 167 ms 23976 KB Output is correct
23 Correct 153 ms 23936 KB Output is correct
24 Correct 170 ms 23968 KB Output is correct
25 Correct 62 ms 14068 KB Output is correct
26 Correct 61 ms 14064 KB Output is correct
27 Correct 153 ms 23976 KB Output is correct
28 Correct 157 ms 23964 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 300 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 1 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 9 ms 1100 KB Output is correct
7 Correct 180 ms 22024 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 300 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 1256 KB Output is correct
13 Correct 155 ms 23936 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 82 ms 14072 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 38 ms 6260 KB Output is correct
21 Correct 154 ms 24024 KB Output is correct
22 Correct 167 ms 23976 KB Output is correct
23 Correct 153 ms 23936 KB Output is correct
24 Correct 170 ms 23968 KB Output is correct
25 Correct 62 ms 14068 KB Output is correct
26 Correct 61 ms 14064 KB Output is correct
27 Correct 153 ms 23976 KB Output is correct
28 Correct 157 ms 23964 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Incorrect 1 ms 212 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -