# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
302868 | nadidadit | Connecting Supertrees (IOI20_supertrees) | C++17 | 1 ms | 256 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 "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
vector<vector<int>> b;
int construct(vector<std::vector<int>> p) {
n = p.size();
b.resize(n);
for(int i = 0; i < n; ++i) b[i].resize(n);
int adit[n];
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
b[i][j]=0;
adit[i]=0;
}
}
for(int i=0;i<n;i++)
{
if(p[i][i]!=1)
{
return 0;
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(p[i][j]!=p[j][i])
{
return 0;
}
}
}
for(int i=0;i<n;i++)
{
vector<int>check;
if(adit[i]==0)
{
check.push_back(i);
for(int j=0;j<n;j++)
{
if(p[i][j]==2)
{
if(adit[j]==1)
{
return 0;
}
check.push_back(j);
}
}
if(check.size()>2)
{
for(int i=0;i<check.size()-1;i++)
{
b[check[i]][check[i+1]]=1;
adit[check[i]]=1;
b[check[i+1]][check[i]]=1;
}
adit[check[check.size()-1]]=1;
b[0][check[check.size()-1]]=1;
b[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(p[check[i]][check[j]]!=2 || p[check[i]][check[j]]!=2)
{
return 0;
}
else
{
p[check[i]][check[j]]=0;
p[check[j]][check[i]]=0;
}
}
}
}
}
check.clear();
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(i!=j && p[i][j]==2)
{
return 0;
}
}
}
build(b);
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... |