Submission #788271

# Submission time Handle Problem Language Result Execution time Memory
788271 2023-07-20T04:18:03 Z mannshah1211 Connecting Supertrees (IOI20_supertrees) C++17
11 / 100
172 ms 21924 KB
#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;



void build(vector<vector<int>> b);

struct DSU {
	vector<int> link, siz;
	DSU (int n) : link(n), siz(n, 1) {
		iota(link.begin(), link.end(), 0ll);
	}
	
	int get(int x) {
		if (link[x] == x) {
			return x;
		}
		return link[x] = get(link[x]);
	}
	
	bool unite(int a, int b) {
	   a = get(a), b = get(b);
	   if (a == b) {
	   	return false;
	   }
	   
	   if (siz[a] < siz[b]) {
	   	swap(a, b);
	   }
	   link[b] = a;
	   siz[a] += siz[b];
	   return true;
	}
	
	bool same(int a, int b) {
		return (get(a) == get(b));
	}
	
};

int construct(vector<vector<int>> p) {
	vector<vector<int>> b(p.size(), vector<int>(p.size()));
	for (int i = 0; i < p.size() - 1; i++) {
		b[i][i + 1] = 1;
		b[i + 1][i] = 1;
	}
	build(b);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for (int i = 0; i < p.size() - 1; i++) {
      |                  ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 7 ms 1104 KB Output is correct
7 Correct 172 ms 21924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 7 ms 1104 KB Output is correct
7 Correct 172 ms 21924 KB Output is correct
8 Incorrect 0 ms 212 KB Too many ways to get from 0 to 1, should be 0 found no less than 1
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Too many ways to get from 0 to 1, should be 0 found no less than 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Too many ways to get from 0 to 1, should be 0 found no less than 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 7 ms 1104 KB Output is correct
7 Correct 172 ms 21924 KB Output is correct
8 Incorrect 0 ms 212 KB Too many ways to get from 0 to 1, should be 0 found no less than 1
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 7 ms 1104 KB Output is correct
7 Correct 172 ms 21924 KB Output is correct
8 Incorrect 0 ms 212 KB Too many ways to get from 0 to 1, should be 0 found no less than 1
9 Halted 0 ms 0 KB -