Submission #421235

#TimeUsernameProblemLanguageResultExecution timeMemory
421235JUANDI321슈퍼트리 잇기 (IOI20_supertrees)C++17
0 / 100
1 ms204 KiB
#include "supertrees.h"
#include <vector>
#include <deque>

using namespace std;
bool ch[1010];

int construct(vector<vector<int>> p) {
	int n = p.size();
	vector<vector<int>> answer;
	for (int i = 0; i < n; i++) 
	{
		vector<int> row;
		row.resize(n);
		answer.push_back(row);
	}
	for(int i = 0; i<n; i++)
	{
		for(int j = i+1; j<n; j++)
		{
			if(p[i][j] == 0)
			{
				for(int h = 0; h < n; h++)
				{
					if(p[i][h] == 1 && p[j][h] == 1)return 0;
				}
			}
		}
	}
	deque<int> l;
	for(int i = 0; i<n; i++)
	{
		if(!ch[i])
		{
			ch[i]=true;
			//l.clear();
			int ant = i;
			for(int j = 0; j<n; j++)
			{
				if(p[i][j] == 1)
				{
					ch[j]=true;
					answer[ant][j]=1;
					answer[j][ant]=1;
					ant = j;
				}
			}
		}
	}
	build(answer);
	return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...