Submission #301782

#TimeUsernameProblemLanguageResultExecution timeMemory
301782Pro100YanConnecting Supertrees (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
#include "supertrees.h" #include <vector> #include <iostream> #define ll long long #define pb push_back using namespace std; const int N = 2005; vector<vector<int>> ans; int get_parent(int v){ if(v == d[v]) return v; return d[v] = get_parent(d[v]); } void add(int u, int v){ int f = get_parent(u), s = get_parent(v); if(f != s) d[f] = d[s]; } int construct(std::vector<std::vector<int>> p) { int n = p.size(); int fault = 0; for(int i = 0; i < n; i++) d[i] = i; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); ans.push_back(row); } for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(p[i][j]){ add(i, j); } } } int pi, pj; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ pi = get_parent(i); pj = get_parent(j); } if(p[i][j]){ if(pi != pj) return 0; ans[i][pi] = ans[pi][i] = 1; ans[j][pi] = ans[pi][j] = 1; } else{ if(pi == pj) return 0; } } build(ans); return 1; } /* 5 1 0 0 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 1 1 1 0 0 1 1 */

Compilation message (stderr)

supertrees.cpp: In function 'int get_parent(int)':
supertrees.cpp:13:13: error: 'd' was not declared in this scope
   13 |     if(v == d[v])
      |             ^
supertrees.cpp:15:12: error: 'd' was not declared in this scope
   15 |     return d[v] = get_parent(d[v]);
      |            ^
supertrees.cpp: In function 'void add(int, int)':
supertrees.cpp:21:9: error: 'd' was not declared in this scope
   21 |         d[f] = d[s];
      |         ^
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:30:9: error: 'd' was not declared in this scope
   30 |         d[i] = i;
      |         ^
supertrees.cpp:50:17: error: 'j' was not declared in this scope
   50 |         if(p[i][j]){
      |                 ^
supertrees.cpp:28:6: warning: unused variable 'fault' [-Wunused-variable]
   28 |  int fault = 0;
      |      ^~~~~