답안 #451961

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
451961 2021-08-03T14:20:10 Z rainboy 슈퍼트리 잇기 (IOI20_supertrees) C++17
0 / 100
0 ms 204 KB
#include "supertrees.h"
#include <string.h>

using namespace std;

typedef vector<int> vi;

const int N = 1000;

int abs_(int a) { return a > 0 ? a : -a; }

int ds[N];

int find(int i) {
	return ds[i] < 0 ? i : (ds[i] = find(ds[i]));
}

void join(int i, int j) {
	i = find(i);
	j = find(j);
	if (i == j)
		return;
	if (ds[i] > ds[j])
		ds[i] = j;
	else {
		if (ds[i] == ds[j])
			ds[i]--;
		ds[j] = i;
	}
}

int construct(vector<vi> pp) {
	int n = pp.size(), i, j;
	vector<vi> aa(n);

	memset(ds, -1, n * sizeof *ds);
	for (i = 0; i < n; i++)
		aa[i].resize(n), aa[i][i] = 1;
	for (i = 0; i < n; i++)
		for (j = i + 1; j < n; j++)
			if (aa[i][j] == 1)
				join(i, j);
	for (i = 0; i < n; i++)
		for (j = i + 1; j < n; j++)
			if ((find(i) == find(j)) != (aa[i][j] == 1))
				return 0;
	for (i = 0; i < n; i++)
		if ((j = find(i)) != i)
			aa[i][j] = aa[j][i] = 1;
	build(aa);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -