Submission #953737

#TimeUsernameProblemLanguageResultExecution timeMemory
953737Trisanu_DasConnecting Supertrees (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "supertrees.h" int n, par[1005]; int find(int u){ return (par[u] == u ? u : find(par[u])); } void union(int u, int v){ par[find(u)] = find(b); } int construct(vector<vector<int> > p){ n = p.size(); for(int i = 0; i < n; i++) par[i] = i; vector<vector<int> > b(n, vector<int>(n)); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(p[i][j] && find(i) != find(j)){ union(i, j); adj[i][j] = adj[j][i] = 1; }else if(!p[i][j] && find(i) == find(j)) return 0; } } build(b); return 1; }

Compilation message (stderr)

supertrees.cpp:11:11: error: expected identifier before '(' token
   11 | void union(int u, int v){
      |           ^
supertrees.cpp:11:12: error: expected unqualified-id before 'int'
   11 | void union(int u, int v){
      |            ^~~
supertrees.cpp:11:12: error: expected ')' before 'int'
   11 | void union(int u, int v){
      |           ~^~~
      |            )
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:22:9: error: expected primary-expression before 'union'
   22 |         union(i, j);
      |         ^~~~~
supertrees.cpp:23:9: error: 'adj' was not declared in this scope
   23 |         adj[i][j] = adj[j][i] = 1;
      |         ^~~