Submission #953738

# Submission time Handle Problem Language Result Execution time Memory
953738 2024-03-26T15:18:16 Z Trisanu_Das Connecting Supertrees (IOI20_supertrees) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#include "supertrees.h"
 
int n, par[1005];
 
int find(int u){
  return (par[u] == u ? u : find(par[u]));
}
 
void union_(int u, int v){
  par[find(u)] = find(b);
}
 
int construct(vector<vector<int> > p){
  n = p.size();
  for(int i = 0; i < n; i++) par[i] = i;
  vector<vector<int> > b(n, vector<int>(n));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(p[i][j] && find(i) != find(j)){
        union_(i, j);
        b[i][j] = b[j][i] = 1;
      }else if(!p[i][j] && find(i) == find(j)) return 0;
    }
  }
  build(b);
  return 1;
}

Compilation message

supertrees.cpp: In function 'void union_(int, int)':
supertrees.cpp:12:23: error: 'b' was not declared in this scope
   12 |   par[find(u)] = find(b);
      |                       ^