Submission #771481

# Submission time Handle Problem Language Result Execution time Memory
771481 2023-07-03T04:30:00 Z ono_de206 Connecting Supertrees (IOI20_supertrees) C++14
0 / 100
1 ms 336 KB
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int mxn = 1010;
int par[mxn];

int get(int x) {
	return (x == par[x] ? x : par[x] = get(par[x]));
}

void unite(int x, int y) {
	x = get(x); y = get(y);
	if(x == y) return;
	par[y] = x;
}

int construct(vector<vector<int>> p) {
	int n = p.size();
	vector<vector<int>> answer(n, vector<int>(n));
	for(int i = 0; i < n; i++) {
		par[i] = i;
	}
	int mx = 0;
	for (int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(p[i][j] > 0) {
				unite(i, j);
				mx = max(mx, p[i][j]);
			} 
		}
	}
	if(mx == 0) {
		build(answer);
		return 1;
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(p[i][j] == 0 && get(i) == get(j)) {
				return 0;
			}
		}
	}
	vector<int> vis(n);
	for(int i = 0; i < n; i++) {
		if(vis[i]) continue;
		int ls = i;
		for(int j = i + 1; j < n; j++) {
			if(get(j) == get(i)) {
				answer[ls][j] = answer[j][ls] = 1;
			}
		}
	}
	build(answer);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 304 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 Correct 1 ms 308 KB Output is correct
3 Incorrect 0 ms 212 KB Too many ways to get from 1 to 4, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -