Submission #302972

#TimeUsernameProblemLanguageResultExecution timeMemory
302972dolijanConnecting Supertrees (IOI20_supertrees)C++14
0 / 100
3 ms640 KiB
#include "supertrees.h" #include <vector> #include <bits/stdc++.h> using namespace std; const int mn=1100; vector<int> parent(mn); vector<int> velicina(mn); int find_parent(int node) { if(parent[node]==node) return node; return parent[node]=find_parent(parent[node]); } int join(int a,int b) { int pa=find_parent(a); int pb=find_parent(b); if(velicina[pa]<velicina[pb]) { parent[pa]=pb; velicina[pb]+=velicina[pa]; } else { parent[pb]=pa; velicina[pb]+=velicina[pa]; } } int construct(std::vector<std::vector<int> > p) { int n=p.size(); vector<vector<int> > b(n); for(int i=0;i<n;i++) { parent[i]=i; velicina[i]=1; } for(int i=0;i<n;i++) { for(int j=0;j<n;j++) b[i].push_back(false); } for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { if(p[i][j]==1) { b[i][j]=b[j][i]=true; join(i,j); } else { if(find_parent(i)==find_parent(j)) return 0; } } } build(b); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int join(int, int)':
supertrees.cpp:27:1: warning: no return statement in function returning non-void [-Wreturn-type]
   27 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...