# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
847009 | 12345678 | Connecting Supertrees (IOI20_supertrees) | C++17 | 162 ms | 22096 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;
const int nx=1e3+5;
int gc;
bool vs[nx];
vector<vector<int>> g(nx);
int construct(std::vector<std::vector<int>> p) {
int n = p.size();
vector<vector<int>> answer(n, vector<int> (n));
for (int i=0; i<n; i++)
{
if (!vs[i])
{
queue<int> q;
q.push(i); vs[i]=1;
while (!q.empty())
{
int x=q.front(); q.pop();
g[gc].push_back(x);
for (int j=0; j<n; j++) if (p[i][j]&&!vs[j]) q.push(j), vs[j]=1;
}
for (auto x:g[gc]) for (auto y:g[gc]) if (!p[x][y]) return 0;
for (int j=0; j<g[gc].size()-1; j++) answer[g[gc][j]][g[gc][j+1]]=answer[g[gc][j+1]][g[gc][j]]=1;
gc++;
}
}
build(answer);
return 1;
}
/*
5
1 1 1 0 0
1 1 1 0 0
1 1 1 0 0
0 0 0 1 1
0 0 0 1 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... |