Submission #1015801

#TimeUsernameProblemLanguageResultExecution timeMemory
1015801XJP12Connecting Supertrees (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; int n; struct UF{ vi e; UF(int n){ e.resize(n,-1);} int find(int x){ return (e[x] > 0 ? x : find(-e[x])); } void _union(int a, int b){ int x = find(a); int y = find(b); if(x == y) return; if(e[x] < e[y]) swap(x,y); e[x] += e[y]; e[y] = -x; } }; int construct(vvi p){ n = p.size(); int ban=0; UF fu(n); vvi ans(n, vi(n,0)); vvi conect(n, vi()); for(int i=0; i<n; i++){ for(int j=i; j<n; j++){ if(i==j) continue; if(p[i][j]==1 && ban==0){ ban=1; } if(p[i][j]==2 && ban==0){ ban=2; } if(p[i][j]!=0){ fu._union(i, j); } } } for(int i=0; i<n; i++){ for(int j=i; j<n; j++){ if(p[i][j]==0){ if(fu.find(i)==fu.find(j)){ return 0; } }else{ int t = fu.find(i); conect[t].push_back(i); conect[t].push_back(j); } } } for(int i=0; i<n; i++){ for(int j=0; j<(int)conect.size(); j++){ ans[i][conect[i][j]]=1; } if(ban==2){ ans[conect[i][(int)conect.size()-1]][i]=1; } } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(vvi)':
supertrees.cpp:63:2: error: 'build' was not declared in this scope
   63 |  build(ans);
      |  ^~~~~