# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
985743 | user736482 | Connecting Supertrees (IOI20_supertrees) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "supertrees.h"
using namespace std;
vector<pair<int,int>>edges;
int n;
int construct(vector<vector<int>> p){
n=(int)p.size();
int odp[n][n];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
odp[i][j]=0;
}
}
bool ifdeleted[n];
for(int i=0;i<n;i++){
ifdeleted[i]=0;
}
for(int i=0;i<n;i++){
if(ifdeleted[i])
continue;
vector<int>same;
for(int j=0;j<n;j++){
if(p[i][j]==1){
if(p[i]==p[j])
same.push_back(j);
else
return 0;
}
}
for(int j=1;j<(int)same.size();j++){
edges.push_back({same[j-1],same[j]});
ifdeleted[same[j]]=1;
for(int k=0;k<n;k++){
p[k][same[j]]=-1;
}
}
}
for(int i=0;i<(int)edges.size();i++){
//cout<<edges[i].first<<" "<<edges[i].second<<"\n";
odp[edges[i].first][edges[i].second]=1;
odp[edges[i].second][edges[i].first]=1;
}
build(odp);
return 1;
}
/*int main(){
construct({{1, 1, 2, 2}, {1, 1, 2, 2}, {2, 2, 1, 2}, {2, 2, 2, 1}});
return 0;
}*/