Submission #319748

#TimeUsernameProblemLanguageResultExecution timeMemory
319748NicolaAbusaad2014Connecting Supertrees (IOI20_supertrees)C++14
11 / 100
268 ms22116 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; vector<long>parent; std::vector<std::vector<int> > answer; long find_set(long x) { if(parent[x]==x){ return x; } long z=find_set(parent[x]); parent[x]=z; return z; } void union_set(long x,long z) { x=find_set(x); z=find_set(z); if(x!=z){ parent[z]=x; answer[x][z]=1; answer[z][x]=1; } } int construct(std::vector<std::vector<int> > p) { int n = p.size(); for(long i=0;i<n;i++){ parent.push_back(i); } for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); answer.push_back(row); } bool ok=true; for(long i=0;i<n;i++){ for(long j=i+1;j<n;j++){ if(p[i][j]==0){ if(find_set(i)==find_set(j)){ ok=false; i=n; break; } } else{ union_set(i,j); } } } if(ok){ build(answer); return 1; } return 0; }
#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...