Submission #824965

# Submission time Handle Problem Language Result Execution time Memory
824965 2023-08-14T12:40:39 Z Halym2007 Connecting Supertrees (IOI20_supertrees) C++17
11 / 100
165 ms 31964 KB
#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
#define pb push_back
const int N = 1005;
int a[N][N], o;
bool vis[N];
vector <int> v[N];
void dfs (int x, int pr) {
	if (pr != -1) {
		a[pr][x] = a[x][pr] = 1;
	}
	vis[x] = o;
	for (int i : v[x]) {
		if (vis[i]) continue;
		dfs (i, x);
	}
}
int construct(vector<vector<int>> p) {
	int n = p.size();
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
		  if (i == j) continue;
			if (p[i][j]) {
				v[i].pb (j);
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		if (!vis[i]) {
			o++;
			dfs (i, -1);
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j) continue;
			if ((p[i][j] == 1) and (vis[i] != vis[j])) return 0;
			if (p[i][j] == 0 and vis[i] == vis[j]) return 0;
		}
	}
	vector<vector<int>> answer;
	for (int i = 0; i < n; i++) {
		vector<int> row;
		row.resize(n);
		for (int j = 0; j < n; ++j) {
			if (a[i][j]) row[j] = 1;
		}
		answer.push_back(row);
	}
	build(answer);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 7 ms 2264 KB Output is correct
7 Correct 165 ms 31964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 7 ms 2264 KB Output is correct
7 Correct 165 ms 31964 KB Output is correct
8 Incorrect 0 ms 340 KB Answer gives possible 0 while actual possible 1
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 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 212 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 7 ms 2264 KB Output is correct
7 Correct 165 ms 31964 KB Output is correct
8 Incorrect 0 ms 340 KB Answer gives possible 0 while actual possible 1
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 7 ms 2264 KB Output is correct
7 Correct 165 ms 31964 KB Output is correct
8 Incorrect 0 ms 340 KB Answer gives possible 0 while actual possible 1
9 Halted 0 ms 0 KB -