답안 #792040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
792040 2023-07-24T14:13:30 Z mousebeaver 슈퍼트리 잇기 (IOI20_supertrees) C++14
11 / 100
146 ms 21964 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(adjmatrix[i].begin(), adjmatrix[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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 146 ms 21964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 146 ms 21964 KB Output is correct
8 Incorrect 1 ms 212 KB Answer gives possible 0 while actual possible 1
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 146 ms 21964 KB Output is correct
8 Incorrect 1 ms 212 KB Answer gives possible 0 while actual possible 1
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 146 ms 21964 KB Output is correct
8 Incorrect 1 ms 212 KB Answer gives possible 0 while actual possible 1
9 Halted 0 ms 0 KB -