# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1207783 | tamzid | Connecting Supertrees (IOI20_supertrees) | C++20 | 0 ms | 0 KiB |
#include "supertrees.h"
#include <vector>
using namespace std;
int construct(std::vector<std::vector<int>> p) {
int n = p.size();
if(n == 1)
{
build({{0}});
return 1;
}
vector<vector<int>> a(n,vector<int>(n,0));
for(int i=0;i<n;++i)
{
a[i-1][i] = 1;
a[i][i-1] = 1;
}
build(a);
return 1;
}
#include "supertrees.h"
#include <vector>
using namespace std;
int construct(std::vector<std::vector<int>> p) {
int n = p.size();
if(n == 1)
{
build({{0}});
return 1;
}
vector<vector<int>> a(n,vector<int>(n,0));
for(int i=1;i<n;++i)
{
a[0][i] = 1;
a[i][0] = 1;
}
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
if(p[i][j] != a[i][j])
{
a[i][j] = p[i][j];
}
}
}
build(a);
return 1;
}