# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
302867 | nadidadit | 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>
using namespace std;
int main()
{
int n;
cin>>n;
int arra[n][n],adit[n],ans[n][n];
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
ans[i][j]=0;
adit[i]=0;
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cin>>arra[i][j];
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(arra[i][j]!=arra[j][i])
{
cout<<"BYE"<<endl;
return 0;
}
}
}
for(int i=0;i<n;i++)
{
if(arra[i][i]!=1)
{
cout<<"Biday"<<endl;
return 0;
}
}
int count=0,past;
for(int i=0;i<n;i++)
{
vector<int>check;
check.push_back(i);
if(adit[i]==0)
{
for(int j=0;j<n;j++)
{
if(arra[i][j]==2)
{
if(adit[j]==1)
{
cout<<"Bad Luck"<<endl;
return 0;
}
// cout<<"i= "<<i<<" j= "<<j<<" past= "<<past<<" count= "<<count<<" adit["<<i<<"]= "<<adit[i]<<" adit["<<j<<"]= "<<adit[j]<<" adit["<<past<<"]= "<<adit[past]<<endl;
// cout<<"arra["<<i<<"]["<<j<<"]= "<<arra[i][j]<<endl;
check.push_back(j);
}
}
if(check.size()>2)
{
// cout<<"size= "<<check.size()<<endl;
for(int i=0;i<check.size();i++)
{
cout<<check[i]<<" ";
}
cout<<endl;
for(int i=0;i<check.size()-1;i++)
{
ans[check[i]][check[i+1]]=1;
adit[check[i]]=1;
ans[check[i+1]][check[i]]=1;
}
adit[check[check.size()-1]]=1;
ans[check[0]][check[check.size()-1]]=1;
ans[check[check.size()-1]][0]=1;
for(int i=0;i<check.size();i++)
{
for(int j=0;j<check.size();j++)
{
if(i!=j)
{
if(arra[check[i]][check[j]]!=2 || arra[check[i]][check[j]]!=2)
{
cout<<"NO"<<endl;
return 0;
}
else
{
arra[check[i]][check[j]]=0;
arra[check[j]][check[i]]=0;
}
}
}
}
}
check.clear();
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(i!=j && arra[i][j]==2)
{
cout<<"Bye Bye"<<endl;
return 0;
}
}
}
/* for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
// cout<<arra[i][j]<<" ";
}
cout<<endl;
}*/
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cout<<ans[i][j]<<" ";
}
cout<<endl;
}
return 0;
}