Submission #381880

#TimeUsernameProblemLanguageResultExecution timeMemory
381880pavementConnecting Supertrees (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int link[1005], sz[1005]; vector<int> vec[1005]; int find(int x) { if (x == link[x]) return x; return link[x] = find(link[x]); } void unite(int a, int b) { a = find(a); b = find(b); if (sz[b] > sz[a]) swap(a, b); sz[a] += sz[b]; for (int i : vec[b]) vec[a].push_back(i); link[b] = a; } int construct(vector<vector<int> > p) { int n = p.size(); for (int i = 0; i < n; i++) { link[i] = i; sz[i] = 1; vec[i].push_back(i); } vector<vector<int> > b(n, vector<int>(n)); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) if (p[i][j]) unite(i, j); } for (int i = 0; i < n; i++) { if (find(i) != i) continue; int prv = -1; for (int j : vec[i]) { if (prv != -1) b[prv][j] = b[j][prv] = 1; prv = j; } } build(b); return 1; }

Compilation message (stderr)

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