Submission #317726

#TimeUsernameProblemLanguageResultExecution timeMemory
317726amunduzbaev슈퍼트리 잇기 (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
#include "grader.cpp"
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
#define pb(a) push_back(a) 

const int N=1005;
int used[N];

int construct(vector<vector<int>> p) {
	int n = p.size();
	vector<vector<int> > b(n), ones(n), twos(n);

		for(int i=0;i<n;i++){
			b[i].resize(n);
			for(int j=0;j<n;j++){
				b[i][j] = 0;
				if(i!=j && p[i][j] == 1)
					ones[i].pb(j);
				if(i!=j && p[i][j] == 2)
					twos[i].pb(j);
				if(p[i][j] == 3) return 0;
			}
			for(int j=0;j<ones[i].size(); j++){
				for(int l=j+1;l<ones[i].size();l++)
					if(p[ones[i][j]][ones[i][l]] != 1) return 0;
				for(int l=0;l<twos[i].size();l++)
					if(p[ones[i][j]][twos[i][l]] != 2) return 0;
			}
			if(twos[i].size() == 1) return 0;
			for(int j=0;j<twos[i].size(); j++){
				for(int l=0;l<ones[i].size();l++)
					if(p[twos[i][j]][ones[i][l]] != 2) return 0;
				for(int l=j+1;l<twos[i].size();l++)
					if(p[twos[i][j]][twos[i][l]] != 2) return 0;
			}
		}
		for(int i=0;i<n;i++){
			if(used[i]) continue;
			for(int j=0;j<ones[i].size();j++){
				used[ones[i][j]] = 1;
				b[i][ones[i][j]] = 1;
				b[ones[i][j]][i] = 1;
			}
			if(twos[i].size() == 0) continue;
			int j = 0, sz = twos[i].size();
			b[i][twos[i][j]] = 1;
			b[twos[i][j]][i] = 1;
			for(;j<sz-1; j++){
				used[twos[i][j]] = 1;
				b[twos[i][j]][twos[i][j+1]] = 1;
				b[twos[i][j+1]][twos[i][j]] = 1;
			}
			used[twos[i][j]] = 1;
			b[i][twos[i][j]] = 1;
			b[twos[i][j]][i] = 1;
		}
		build(b);
		return 1;
	
	return 0;
}
/*

5
0 2 2 2 2
2 0 2 2 2
2 2 0 2 2
2 2 2 0 2 
2 2 2 2 0

3
1 2 2
2 1 2 
2 2 1

4
1 1 2 2 
1 1 2 2 
2 2 1 2 
2 2 2 1 

5
1 2 2 2 0
2 1 2 2 0
2 2 1 2 0
2 2 2 1 0
0 0 0 0 1

*/

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |    for(int j=0;j<ones[i].size(); j++){
      |                ~^~~~~~~~~~~~~~~
supertrees.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int l=j+1;l<ones[i].size();l++)
      |                   ~^~~~~~~~~~~~~~~
supertrees.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int l=0;l<twos[i].size();l++)
      |                 ~^~~~~~~~~~~~~~~
supertrees.cpp:31:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |    for(int j=0;j<twos[i].size(); j++){
      |                ~^~~~~~~~~~~~~~~
supertrees.cpp:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int l=0;l<ones[i].size();l++)
      |                 ~^~~~~~~~~~~~~~~
supertrees.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int l=j+1;l<twos[i].size();l++)
      |                   ~^~~~~~~~~~~~~~~
supertrees.cpp:40:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |    for(int j=0;j<ones[i].size();j++){
      |                ~^~~~~~~~~~~~~~~
/tmp/cc6rgWFN.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc9uAGCl.o:supertrees.cpp:(.text.startup+0x0): first defined here
/tmp/cc6rgWFN.o: In function `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)':
grader.cpp:(.text+0x1d0): multiple definition of `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
/tmp/cc9uAGCl.o:supertrees.cpp:(.text+0x1d0): first defined here
collect2: error: ld returned 1 exit status