답안 #981495

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
981495 2024-05-13T09:24:36 Z tamir1 슈퍼트리 잇기 (IOI20_supertrees) C++17
0 / 100
1 ms 348 KB
#include "supertrees.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int sz[1001],par[1001];
int find(int a){
	if(a==par[a]) return a;
	int x=find(par[a]);
	par[a]=x;
	return x;
}
int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	for(int i=0;i<n;i++){
		sz[i]=1;
		par[i]=i;
		for(int j=0;j<n;j++){
			if(p[i][j]==3) return 0;
		}
	}
	if(n==1){
		build({{0}});
		return 1;
	}
	std::vector<std::vector<int>> answer(n,vector<int> (n,0));
	for (int i = 0; i < n; i++) {
		for(int j=0;j<n;j++){
			int x=find(i);
			int y=find(j);
			if(p[i][j]==0 && x==y) return 0;
			if(p[i][j]==1){
				if(x==y) continue;
				if(sz[x]<sz[y]) swap(x,y);
				else if(sz[x]==sz[y] && x>y) swap(x,y);
				sz[x]+=sz[y];
				par[y]=x;
			}
		}
	}
	build(answer);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 2 found 0
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -