Submission #977678

# Submission time Handle Problem Language Result Execution time Memory
977678 2024-05-08T09:06:19 Z SmuggingSpun Connecting Supertrees (IOI20_supertrees) C++14
21 / 100
176 ms 20304 KB
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
int construct(vector<vector<int>>p){
	int n = p.size();
	bool is_sub1 = true;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(p[i][j] != 1){
				is_sub1 = false;
				i = n;
				break;
			}
		}
	}
	if(is_sub1){
		p = vector<vector<int>>(n, vector<int>(n, 0));
		for(int i = 1; i < n; i++){
			p[i][i - 1] = p[i - 1][i] = 1;
		}
		build(p);
		return 1;
	}
	vector<int>par(n);
	iota(par.begin(), par.end(), 0);
	function<int(int)>find_set;
	find_set = [&] (int n){
		return n == par[n] ? n : par[n] = find_set(par[n]);	
	};
	function<void(int, int)>merge = [&] (int a, int b){
		par[find_set(a)] = find_set(b);
	};
	vector<bool>vis(n, false);
	vector<vector<int>>edge(n);
	for(int i = 0; i < n; i++){
		if(vis[i]){
			for(int j = 0; j < n; j++){
				if(i != j && int(find_set(i) == find_set(j)) != p[i][j]){
					return 0;
				}
			}
			continue;
		}
		for(int j = 0; j < n; j++){
			if(i != j && p[i][j] == 0 && find_set(i) == find_set(j)){
				return 0;
			}
			if(p[i][j] == 1){
				merge(i, j);
				vis[j] = true;
			}
		}
	}
	for(int i = 0; i < n; i++){
		edge[find_set(i)].emplace_back(i);
	}
	p = vector<vector<int>>(n, vector<int>(n, 0));
	for(int i = 0; i < n; i++){
		for(int j = 1; j < edge[i].size(); j++){
			p[edge[i][j]][edge[i][j - 1]] = p[edge[i][j - 1]][edge[i][j]] = 1;
		}
	}
	build(p);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:59:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |   for(int j = 1; j < edge[i].size(); j++){
      |                  ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 1116 KB Output is correct
7 Correct 164 ms 18196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 1116 KB Output is correct
7 Correct 164 ms 18196 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 7 ms 1116 KB Output is correct
13 Correct 154 ms 20304 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 68 ms 10156 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 41 ms 5360 KB Output is correct
21 Correct 176 ms 20232 KB Output is correct
22 Correct 157 ms 20048 KB Output is correct
23 Correct 172 ms 20224 KB Output is correct
24 Correct 169 ms 20012 KB Output is correct
25 Correct 70 ms 10068 KB Output is correct
26 Correct 60 ms 10120 KB Output is correct
27 Correct 176 ms 19988 KB Output is correct
28 Correct 153 ms 20216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 432 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 348 KB Output is correct
2 Incorrect 0 ms 348 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 348 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 1116 KB Output is correct
7 Correct 164 ms 18196 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 7 ms 1116 KB Output is correct
13 Correct 154 ms 20304 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 68 ms 10156 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 41 ms 5360 KB Output is correct
21 Correct 176 ms 20232 KB Output is correct
22 Correct 157 ms 20048 KB Output is correct
23 Correct 172 ms 20224 KB Output is correct
24 Correct 169 ms 20012 KB Output is correct
25 Correct 70 ms 10068 KB Output is correct
26 Correct 60 ms 10120 KB Output is correct
27 Correct 176 ms 19988 KB Output is correct
28 Correct 153 ms 20216 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 0 ms 432 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 1116 KB Output is correct
7 Correct 164 ms 18196 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 7 ms 1116 KB Output is correct
13 Correct 154 ms 20304 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 68 ms 10156 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 41 ms 5360 KB Output is correct
21 Correct 176 ms 20232 KB Output is correct
22 Correct 157 ms 20048 KB Output is correct
23 Correct 172 ms 20224 KB Output is correct
24 Correct 169 ms 20012 KB Output is correct
25 Correct 70 ms 10068 KB Output is correct
26 Correct 60 ms 10120 KB Output is correct
27 Correct 176 ms 19988 KB Output is correct
28 Correct 153 ms 20216 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 0 ms 432 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -