Submission #953783

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

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:41:3: error: 'build' was not declared in this scope
   41 |   build(b);
      |   ^~~~~