Submission #1355298

#TimeUsernameProblemLanguageResultExecution timeMemory
1355298Charizard2021슈퍼트리 잇기 (IOI20_supertrees)C++20
Compilation error
0 ms0 KiB
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
int n;
vector<vector<int> > adj;
vector<bool> visited;
bool cycle = false;
void dfs(int u, int p){
	if(visited[u]){
		cycle = true;
		return;
	}
	visited[u] = true;
	for(int v : adj[u]){
		if(v != p){
			dfs(v, u);
		}
	}
}
int construct(vector<vector<int> > p){
	n = p.size();
	sizes.resize(n, 1);
	parent.resize(n);
	adj.resize(n);
	visited.resize(n, false);
	bool has1 = false;
	for(int i = 0; i < n; i++){
		parent[i] = i;
		for(int j = i + 1; j < n; j++){
			if(p[i][j] == 1){
				adj[i].push_back(j);
				adj[j].push_back(i);
				has1 = true;
			}
		}
	}
	for(int i = 0; i < n; i++){
		if(!visited[i]){
			dfs(i, 0);
		}
	}
	if(!cycle){
		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;
	}
}

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:22:9: error: 'sizes' was not declared in this scope; did you mean 'size_t'?
   22 |         sizes.resize(n, 1);
      |         ^~~~~
      |         size_t
supertrees.cpp:23:9: error: 'parent' was not declared in this scope
   23 |         parent.resize(n);
      |         ^~~~~~
supertrees.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type]
   54 | }
      | ^