Submission #666523

#TimeUsernameProblemLanguageResultExecution timeMemory
666523YENGOYAN슈퍼트리 잇기 (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
#include "supertrees.h"
#include <vector>

using namespace std;

vector<int> par, sizes;

int get(int u){
    if(par[u] == u) return u;
    return par[u] = get(par[u]);
}

void union_sets(int u, int v){
    int a = get(u), b = get(v);
    if(a == b) return;
    if(sizes[a] < sizes[b]) swap(a, b);
    par[b] = a;
    sizes[a] += sizes[b];
}

int construct(vector<std::vector<int>> p) {
	int n = p.size();
	vector<vector<bool>> gp(n, vector<bool> (n));
	par = sizes = vector<int> (n);
	for(int i = 0; i < n;i++) par[i] = i, sizes[i] = 1;
	for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(!p[i][j]) continue;
            int u = get(i), v = get(j);
            if(u != v) union_sets(u, v), gp[i][j] = gp[j][i] = 1;
        }
	}
	build(gp);
	return 1;
}

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:33:8: error: could not convert 'gp' from 'vector<vector<bool>>' to 'vector<vector<int>>'
   33 |  build(gp);
      |        ^~
      |        |
      |        vector<vector<bool>>