Submission #807333

# Submission time Handle Problem Language Result Execution time Memory
807333 2023-08-04T16:06:10 Z nemethm Connecting Supertrees (IOI20_supertrees) C++17
11 / 100
140 ms 23916 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<pair<int,int>>> elek;
	for(int i = 0; i < n; ++i){
		bool uj = false;
		if(cmp[i] == 0){
			++id;
			cmp[i] = id;
			uj = true;
			elek.push_back({});
		}
		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, i});
				}
			}
		}
	}
	for(auto& v : elek){
		for(auto i : v){
			answer[i.first][i.second] = answer[i.second][i.first] = 1;
		}
	}
	build(answer);
	return 1;
}
# 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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 140 ms 22016 KB Output is correct
# 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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 140 ms 22016 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 288 KB Output is correct
12 Correct 6 ms 1236 KB Output is correct
13 Correct 137 ms 23916 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 808 KB Output is correct
17 Correct 63 ms 14060 KB Output is correct
18 Correct 0 ms 292 KB Output is correct
19 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
20 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 1 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 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 140 ms 22016 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 288 KB Output is correct
12 Correct 6 ms 1236 KB Output is correct
13 Correct 137 ms 23916 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 808 KB Output is correct
17 Correct 63 ms 14060 KB Output is correct
18 Correct 0 ms 292 KB Output is correct
19 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
20 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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 140 ms 22016 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 288 KB Output is correct
12 Correct 6 ms 1236 KB Output is correct
13 Correct 137 ms 23916 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 808 KB Output is correct
17 Correct 63 ms 14060 KB Output is correct
18 Correct 0 ms 292 KB Output is correct
19 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
20 Halted 0 ms 0 KB -