Submission #770946

# Submission time Handle Problem Language Result Execution time Memory
770946 2023-07-02T07:36:20 Z OrazB Connecting Supertrees (IOI20_supertrees) C++14
0 / 100
1 ms 300 KB
#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
#define N 100005
#define wr cout << "Continue debugging\n";
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second

int find(int i, vector<vector<int>> p, int n){
	set<int> s;
	for (int j = 0; j < n; j++){
		if (p[i][j] and i != j) s.insert(p[i][j]);
	}
	if (s.size() > 1) return -1;
	if (!s.size()) return -2;
	return *s.begin();
}

int construct(vector<vector<int>> p){
	int n = p.size();
	vector<vector<int>> b(n+1, vector<int>(n+1, 0));
	vector<int> vis(n+1, 0);
	for (int i = 0; i < n; i++){
		if (vis[i]) continue; 
		int x = find(i, p, n);
		if (x == -1) return 0;
		if (x == -2) continue;
		vector<int> vec;
		for (int j = 0; j < n; j++){
			if (p[i][j] and i != j) b[i][j] = b[j][i] = vis[j] = 1;
			else if (!p[i][j]) vec.pb(j);
		}
		for (int j = 0; j < n; j++){
			if (!p[i][j] or i == j) continue;
			for (auto k : vec) if (p[j][k]) return 0;
		}
		if (x == 2){
			int a1 = -1, b1 = -1;
			for (int j = 0; j < n; j++){
				if (p[i][j] and i != j){
					if (a1 == -1) a1 = j;
					else b1 = j;
				}
			}
			if (b1 == -1) return 0;
			b[a1][b1] = b[b1][a1] = 1;
		}
	}
	build(b);
	return 1;
}

// int main ()
// {
// }	
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB WA in grader: Invalid number of rows in b
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB WA in grader: Invalid number of rows in b
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: Invalid number of rows in b
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB WA in grader: Invalid number of rows in b
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB WA in grader: Invalid number of rows in b
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB WA in grader: Invalid number of rows in b
2 Halted 0 ms 0 KB -