Submission #732753

# Submission time Handle Problem Language Result Execution time Memory
732753 2023-04-29T09:02:07 Z raul2008487 Connecting Supertrees (IOI20_supertrees) C++17
Compilation error
0 ms 0 KB
#include "supertrees.h"
#include<algorithm>
#include <vector>
std::vector<std::vector<int>> ans;
std::vector<bool> vis;
void dfs(int i, int j){
    vis[j]=1;
    for(int k1=0;k1<n;k1++){
        if(p[j][k1] && !vis[k1]){
            ans[j][k1]=ans[k1][j]=1;
            dfs(j,k1);
        }
    }
}	
int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	vis.resize(n,false);
	for(int i=0;i<n;i++){
	    std::vector<int> row;
	    row.resize(n,0);
	    ans.push_back(row);
	}
	for (int i = 0; i < n; i++) {
	    if(!vis[i]){
	        vis[i]=1;
	        for(int j=i+1;j<n;j++){
		        if(p[i][j] && !vis[j]){ 
		            ans[i][j]=ans[j][i]=1;
		            dfs(i,j);
		        }
		    }
	    }
	}
	build(ans);
	return 1;
}

Compilation message

supertrees.cpp: In function 'void dfs(int, int)':
supertrees.cpp:8:21: error: 'n' was not declared in this scope
    8 |     for(int k1=0;k1<n;k1++){
      |                     ^
supertrees.cpp:9:12: error: 'p' was not declared in this scope
    9 |         if(p[j][k1] && !vis[k1]){
      |            ^