Submission #432314

#TimeUsernameProblemLanguageResultExecution timeMemory
432314arayi슈퍼트리 잇기 (IOI20_supertrees)C++17
46 / 100
256 ms24052 KiB
#include "supertrees.h"
#include <bits/stdc++.h>
#define ad push_back
using namespace std;

const int N = 1111;
int col[N], sm[N], i1 = 1;
vector <vector <int> > b;
int n;
int construct(std::vector<std::vector<int>> p) {
	n = p.size();
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if(p[i][j] > 3) return 0;
	for (int i = 0; i < n; i++)
	{
		if(sm[i])
		{
			for (int j = 0; j < n; j++)
				if(p[i][j] && sm[i] != sm[j]) return 0;
		}
		else
		{
			for (int j = 0; j < n; j++)
				if(p[i][j]) sm[j] = i1;
		}
		i1++;
	}
	b.resize(n);
	for (int i = 0; i < n; i++) b[i].resize(n);
	for (int i = 1; i < i1; i++)
	{
		vector<int> fp;
		for (int j = 0; j < n; j++)
			if(sm[j] == i) fp.ad(j);
		int nx = -1;
		for (int j = 0; j < fp.size(); j++)
		{
			if(col[fp[j]]) continue;
			if(nx != -1) b[nx][fp[j]] = b[fp[j]][nx] = 1;
			nx = fp[j];
			col[fp[j]] = 1;
			for (int k = j + 1; k < fp.size(); k++)
				if(p[fp[j]][fp[k]] == 1) b[fp[j]][fp[k]] = b[fp[k]][fp[j]] = 1, col[fp[k]] = 1;
		}		
		if(nx != -1 && nx != fp[0]) b[nx][fp[0]] = b[fp[0]][nx] = 1;
	}
	build(b);
	return 1;
}

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:37:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for (int j = 0; j < fp.size(); j++)
      |                   ~~^~~~~~~~~~~
supertrees.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |    for (int k = j + 1; k < fp.size(); k++)
      |                        ~~^~~~~~~~~~~
#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...