Submission #880427

#TimeUsernameProblemLanguageResultExecution timeMemory
880427AkibAzmainConnecting Supertrees (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "supertrees.h" #include <vector> int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> ans (n, vector < int > (n)); vector < pair < int, int > > dsu (n); for (int i = 0; i < n; ++i) dsu[i].first = i, dsu[i].second = 1; for (int i = 0; i < n; ++i) for (int j = i + 1; j < n; ++j) if (p[i][j] == 1) { int ci = dsu (i).first, cj = dsu (j).first; while (dsu[ci].first != -1) ci = dsu[ci].first; while (dsu[cj].first != -1) cj = dsu[cj].first; if (ci != cj) { ans[i][j] = ans[j][i] = 1; if (dsu[ci].second < dsu[cj].second) swap (ci, cj); dsu[cj].first = ci; dsu[ci].second += dsu[cj].second; } } for (int i = 0; i < n; ++i) for (int j = i + 1; j < n; ++j) if (p[i][j] == 0) { int ci = dsu (i).first, cj = dsu (j).first; while (dsu[ci].first != -1) ci = dsu[ci].first; while (dsu[cj].first != -1) cj = dsu[cj].first; if (ci == cj) return 0; } build (ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:15:26: error: no match for call to '(std::vector<std::pair<int, int> >) (int&)'
   15 |           int ci = dsu (i).first, cj = dsu (j).first;
      |                          ^
supertrees.cpp:17:22: error: 'cj' was not declared in this scope; did you mean 'ci'?
   17 |           while (dsu[cj].first != -1) cj = dsu[cj].first;
      |                      ^~
      |                      ci
supertrees.cpp:18:21: error: 'cj' was not declared in this scope; did you mean 'ci'?
   18 |           if (ci != cj)
      |                     ^~
      |                     ci
supertrees.cpp:30:26: error: no match for call to '(std::vector<std::pair<int, int> >) (int&)'
   30 |           int ci = dsu (i).first, cj = dsu (j).first;
      |                          ^
supertrees.cpp:32:22: error: 'cj' was not declared in this scope; did you mean 'ci'?
   32 |           while (dsu[cj].first != -1) cj = dsu[cj].first;
      |                      ^~
      |                      ci
supertrees.cpp:33:21: error: 'cj' was not declared in this scope; did you mean 'ci'?
   33 |           if (ci == cj) return 0;
      |                     ^~
      |                     ci