# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
847023 | 12345678 | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 1 ms | 348 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, 0));
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[x][j]==2&&!vs[j]) q.push(j), vs[j]=1;
for (int j=0; j<n; j++) if (p[j][x]==2&&!vs[j]) q.push(j), vs[j]=1;
}
for (auto x:g[gc]) for (auto y:g[gc]) if (p[x][y]==0) return 0;
int s=g[gc].size();
if (s==1)
{
gc++;
continue;
}
for (int j=0; j<g[gc].size(); j++) answer[g[gc][j]][g[gc][(j+1)%s]]=answer[g[gc][(j+1)%s]][g[gc][j]]=1;
gc++;
}
}
build(answer);
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... |