제출 #302787

#제출 시각아이디문제언어결과실행 시간메모리
302787nadidadit슈퍼트리 잇기 (IOI20_supertrees)C++17
0 / 100
1 ms360 KiB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
int n;
vector<vector<int>> b;
 
int construct(vector<std::vector<int>> p) {
	n = p.size();
	b.resize(n);
	for(int i = 0; i < n; ++i)	b[i].resize(n);
	int adit[n];
    	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			b[i][j]=0;
			adit[i]=0;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(p[i][i]!=1)
		{
			return 0;
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(p[i][j]!=p[j][i])
			{
				return 0;
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		vector<int>check;
		if(adit[i]==0)
		{
		for(int j=0;j<n;j++)
		{
			if(p[i][j]==2)
			{
				if(adit[j]==1)
				{
					return 0;
				}
				check.push_back(j);
			}
		}
			if(check.size()>2)
			{
				for(int i=0;i<check.size()-1;i++)
				{
					b[check[i]][check[i+1]]=1;
					adit[check[i]]=1;
					b[check[i+1]][check[i]]=1;
				}
				adit[check[check.size()-1]]=1;
				b[0][check[check.size()-1]]=1;
				b[check[check.size()-1]][0]=1;
				for(int i=0;i<check.size();i++)
				{
					for(int j=0;j<check.size();j++)
					{
						p[check[i]][check[j]]=0;
						p[check[j]][check[i]]=0;
					}
				}
			}
			check.clear();
	}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i!=j && p[i][j]==2)
			{
				return 0;
			}
		}
	}
	build(b);
	return 1;
}

컴파일 시 표준 에러 (stderr) 메시지

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:56:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for(int i=0;i<check.size()-1;i++)
      |                 ~^~~~~~~~~~~~~~~
supertrees.cpp:65:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for(int i=0;i<check.size();i++)
      |                 ~^~~~~~~~~~~~~
supertrees.cpp:67:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |      for(int j=0;j<check.size();j++)
      |                  ~^~~~~~~~~~~~~
#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...