# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078751 | Sir_Ahmed_Imran | Connecting Supertrees (IOI20_supertrees) | C++17 | 132 ms | 24400 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.
///~~~LOTA~~~///
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 1000
int cc[N];
int cn[N];
int vis[N];
int construct(vector<vector<int>> a){
int n,m;
n=a.size();
vector<int> u;
vector<vector<int>> v,x,ans;
for(int i=0;i<n;i++){
if(!vis[i]){
for(int j=i;j<n;j++){
if(a[i][j]==1){
u.append(j);
vis[j]=1;
}
}
v.append(u);
u.clear();
}
vis[i]=0;
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)
u.append(0);
ans.append(u);
u.clear();
}
for(auto& k:v){
for(int i=0;i<k.size();i++){
for(int j=i;j<k.size();j++){
if(a[k[i]][k[j]]!=1)
return 0;
}
}
}
for(int i=0;i<v.size();i++){
if(!vis[i]){
for(auto& j:v[i]){
cn[j]=u.size();
cc[j]=i;
}
u.append(i);
for(int j=i+1;j<v.size();j++){
if(a[v[i][0]][v[j][0]]==2){
for(auto& k:v[j]){
cn[k]=u.size();
cc[k]=i;
}
u.append(j);
vis[j]=1;
}
}
x.append(u);
if(u.size()==2)
return 0;
if(u.size()==1)
x.pop_back();
u.clear();
}
vis[i]=0;
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(cc[i]!=cc[j] && a[i][j]!=0)
return 0;
if(cc[i]==cc[j] && cn[i]==cn[j] && a[i][j]!=1)
return 0;
if(cc[i]==cc[j] && cn[i]!=cn[j] && a[i][j]!=2)
return 0;
}
}
for(auto& i:v){
for(int j=1;j<i.size();j++)
ans[i[j]][i[j-1]]=ans[i[j-1]][i[j]]=1;}
for(auto& i:x){
m=i.size()-1;
for(int j=0;j<m;j++)
ans[v[i[j]][0]][v[i[j+1]][0]]=ans[v[i[j+1]][0]][v[i[j]][0]]=1;
ans[v[i[0]][0]][v[i[m]][0]]=ans[v[i[m]][0]][v[i[0]][0]]=1;
}
build(ans);
return 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |