Submission #329568

# Submission time Handle Problem Language Result Execution time Memory
329568 2020-11-21T15:28:31 Z pggp Connecting Supertrees (IOI20_supertrees) C++14
11 / 100
248 ms 22232 KB
#include <bits/stdc++.h>
#include "supertrees.h"

using namespace std;

vector< vector < int > > comp;
int comp_id[1005];

//void build(vector< vector < int > > p){
//	}

int construct(vector< vector < int > > p){
	int n = p.size();
	for (int i = 0; i < n; ++i)
	{
		bool added = false;
		// sprawdzamy do której składowej należy i
		for(int j = 0; j < comp.size(); j++){
			if(p[i][comp[j][0]] != 0){
				comp[j].push_back(i);
				comp_id[i] = j;
				added = true;
				break;
			}
		}
		if(!added){
			vector < int > v;
			v.push_back(i);
			comp_id[i] = comp.size();
			comp.push_back(v);
		}
	}


	vector < vector < int > > b;
	b.resize(n);
	for (int i = 0; i < n; ++i)
	{
		b[i].resize(n);
		for (int j = 0; j < n; ++j)
		{
			if(p[i][j] == 0 and comp_id[i] == comp_id[j]){
				return 0;
			}
			b[i][j] = 0;
		}
	}

	for(int	i = 0; i < comp.size(); i++){
		for (int j = 1; j < comp[i].size(); ++j)
		{
			b[comp[i][j]][comp[i][j - 1]] = 1;
			b[comp[i][j - 1]][comp[i][j]] = 1;
		}
	}
	build(b);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for(int j = 0; j < comp.size(); j++){
      |                  ~~^~~~~~~~~~~~~
supertrees.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for(int i = 0; i < comp.size(); i++){
      |                 ~~^~~~~~~~~~~~~
supertrees.cpp:50:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for (int j = 1; j < comp[i].size(); ++j)
      |                   ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 10 ms 1260 KB Output is correct
7 Correct 241 ms 22124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 10 ms 1260 KB Output is correct
7 Correct 241 ms 22124 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 13 ms 1260 KB Output is correct
13 Correct 248 ms 22232 KB Output is correct
14 Incorrect 1 ms 364 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Too few ways to get from 0 to 1, should be 2 found 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 10 ms 1260 KB Output is correct
7 Correct 241 ms 22124 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 13 ms 1260 KB Output is correct
13 Correct 248 ms 22232 KB Output is correct
14 Incorrect 1 ms 364 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 10 ms 1260 KB Output is correct
7 Correct 241 ms 22124 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 13 ms 1260 KB Output is correct
13 Correct 248 ms 22232 KB Output is correct
14 Incorrect 1 ms 364 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -