Submission #684634

#TimeUsernameProblemLanguageResultExecution timeMemory
684634KongggwpConnecting Supertrees (IOI20_supertrees)C++14
0 / 100
1 ms212 KiB
#include "supertrees.h" #include<vector> #include<bits/stdc++.h> int par[1000]; using namespace std; int findUpar(int node) { if(node==par[node])return node; return findUpar(par[node]); } void Union(int u , int v) { int pu = findUpar(u) , pv = findUpar(v); par[pu]=pv; } int construct(vector<vector<int>> p) { int n = p.size(); for(int i=0 ; i<n ; i++)par[i]=i; vector<vector<int>>ans(n,vector<int>(n)); for(int i=0 ; i<n ; i++) { for(int j=0 ; j<n ; j++) { if(p[i][j]==3)return 0; if(p[i][j]==1)ans[i][j]=1,Union(i,j); if(p[i][j]==2) { Union(i,j); ans[findUpar(i)][findUpar(j)] = 1; } } } build(ans); return 1; }
#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...