Submission #1014117

# Submission time Handle Problem Language Result Execution time Memory
1014117 2024-07-04T11:17:22 Z 0npata Connecting Supertrees (IOI20_supertrees) C++17
0 / 100
0 ms 348 KB
#include "supertrees.h"
#include<bits/stdc++.h>

using namespace std;

#define vec vector

int construct(vec<vec<int>> p) {
	return 0;

	int n = p.size();

	vec<vec<int>> edges(n, vec<int>(n, 0));

	vec<int> comp(n, -1);

	for(int i = 0; i<n; i++) {
		if(comp[i] != -1) continue;
		for(int j = i; j<n; j++) {
			if(p[i][j] > 0) comp[j] = i;
		}
	}

	for(int i = 0; i<n; i++) {
		for(int j = 0; j<n; j++) {
			if(((p[i][j] > 0) != (comp[i] == comp[j])) || p[i][j] == 3) {
				return 0;
			}
		}
	}

	vec<set<int>> comp_cycle(n);

	vec<int> cycle_chains(n, -1);
	for(int i = 0; i<n; i++) {
		for(int j = 0; j<n; j++) {
			if(p[i][j] == 1) {
				cycle_chains[i] = j;
				comp_cycle[comp[i]].insert(j);
				break;
			}
		}
	}

	for(int i = 0; i<n; i++) {
		for(int j = 0; j<n; j++) {
			if(comp[i] != comp[j]) continue;

			if((cycle_chains[i] == cycle_chains[j]) != (p[i][j] == 1)) {
				return 0;
			}
		}
	}

	for(int i = 0; i<n; i++) {
		if(comp[i] != i) continue;
		assert(comp_cycle[i].size() > 0);

		if(comp_cycle[i].size() == 2) return 0;

		if(comp_cycle[i].size() == 1) continue;

		int prev = *comp_cycle[i].end();
		for(int u : comp_cycle[i]) {
			edges[prev][u] = 1;
			edges[u][prev] = 1;
			prev = u;
		}
	}

	for(int i = 0; i<n; i++) {
		for(int j = i-1; j>=0; j--) {
			if(cycle_chains[i] != -1 && cycle_chains[i] == cycle_chains[j]) {
				edges[i][j] = 1;
				edges[j][i] = 1;
				break;
			}
		}
	}

	build(edges);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -