Submission #666522

#TimeUsernameProblemLanguageResultExecution timeMemory
666522YENGOYANConnecting Supertrees (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
#include "supertrees.h" #include <vector> using namespace std; vector<int> par, sizes; int get(int u){ if(par[u] == u) return u; return par[u] = get(par[u]); } void union_sets(int u, int v){ int a = get(u), b = get(v); if(a == b) return; if(sizes[a] < sizes[b]) swap(a, b); par[b] = a; sizes[a] += sizes[b]; } int construct(vector<std::vector<int>> p) { int n = p.size(); vector<vector<bool>> gp(n, vector<bool> (n)); par = sizes = vector<int> (n); for(int i = 0; i < n;i++) par[i] = i, sizes[i] = 1; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(!p[i][j]) return; int u = get(i), v = get(j); if(u != v) union_sets(u, v), gp[i][j] = gp[j][i] = 1; } } build(gp); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:28:26: error: return-statement with no value, in function returning 'int' [-fpermissive]
   28 |             if(!p[i][j]) return;
      |                          ^~~~~~
supertrees.cpp:33:8: error: could not convert 'gp' from 'vector<vector<bool>>' to 'vector<vector<int>>'
   33 |  build(gp);
      |        ^~
      |        |
      |        vector<vector<bool>>