제출 #1355296

#제출 시각아이디문제언어결과실행 시간메모리
1355296Charizard2021슈퍼트리 잇기 (IOI20_supertrees)C++20
컴파일 에러
0 ms0 KiB
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> sizes;
vector<int> parent;
vector<vector<int> > adj;
int get(int a){
	if(parent[a] == a){
		return a;
	}
	int v = get(parent[a]);
	parent[a] = v;
	return v;
}
bool join(int a, int b){
	a = get(a);
	b = get(b);
	if(a == b){
		return false;
	}
	if(sizes[a] < sizes[b]){
		swap(a, b);
	}
	sizes[a] += sizes[b];
	parent[b] = a;
	return true;
}
int construct(vector<vector<int> > p){
	n = p.size();
	sizes.resize(n, 1);
	parent.resize(n);
	bool has1 = false;
	int comp = n;
	int edj = 0;
	for(int i = 0; i < n; i++){
		parent[i] = i;
		for(int j = i + 1; j < n; j++){
			if(p[i][j] == 1){
				edj++;
				if(dsu.join(i, j)){
					comp--;
				}
				has1 = true;
			}
			if(p[i][j] == 2){
				has2 = true;
			}
		}
	}
	if(edj == n - comp){
		vector<vector<int> > answer(n, vector<int>(n, 0));
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				answer[i][j] = p[i][j];
			}
		}
		build(answer);
	}
	else{
		return 0;
	}
}

컴파일 시 표준 에러 (stderr) 메시지

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:41:36: error: 'dsu' was not declared in this scope
   41 |                                 if(dsu.join(i, j)){
      |                                    ^~~
supertrees.cpp:47:33: error: 'has2' was not declared in this scope; did you mean 'has1'?
   47 |                                 has2 = true;
      |                                 ^~~~
      |                                 has1
supertrees.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
   63 | }
      | ^