Submission #807353

# Submission time Handle Problem Language Result Execution time Memory
807353 2023-08-04T16:15:12 Z nemethm Connecting Supertrees (IOI20_supertrees) C++17
0 / 100
0 ms 212 KB
#include "supertrees.h"
#include <vector>

using namespace std;

int cmp[1010] = {0};

int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	std::vector<std::vector<int>> answer;
	for (int i = 0; i < n; i++) {
		std::vector<int> row;
		row.resize(n);
		answer.push_back(row);
	}
	int id = 0;
	vector<vector<int>> elek;
	for(int i = 0; i < n; ++i){
		bool uj = false;
		if(cmp[i] != 0 && p[i][i] == 1){
			return 0;
		}
		if(cmp[i] == 0){
			++id;
			cmp[i] = id;
			uj = true;
			elek.push_back({i});
		}
		for(int j = 0; j < n; ++j){
			if(j == i) continue;
			if(p[i][j] == 1){
				if(cmp[j] != cmp[i] && !uj){
					return 0;
				}
				else if(uj){
					cmp[j] = cmp[i];
					elek.back().push_back(j);
				}
			}
			else{
				if(cmp[j] == cmp[i]){
					return 0;
				}
			}
		}
	}
	for(auto& v : elek){
		if(v.size() == 2){
			return 0;
		}
		if(v.size() > 2){
			for(int i = 0; i < v.size(); ++i){
				answer[v[i]][v[(i + 1) % v.size()]] = answer[v[(i + 1) % v.size()]][v[i]] = 1;
			}
		}
	}
	build(answer);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:52:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |    for(int i = 0; i < v.size(); ++i){
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Answer gives possible 0 while actual possible 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Answer gives possible 0 while actual possible 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Too few ways to get from 0 to 1, should be 2 found 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Answer gives possible 0 while actual possible 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Answer gives possible 0 while actual possible 1
3 Halted 0 ms 0 KB -