# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
721935 | danikoynov | 슈퍼트리 잇기 (IOI20_supertrees) | C++14 | 263 ms | 30996 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
vector < int > graph[maxn], comp;
int cap[maxn][maxn];
int used[maxn];
vector<std::vector<int>> answer;
void dfs(int v)
{
comp.push_back(v);
used[v] = 1;
for (int u : graph[v])
{
if (!used[u])
dfs(u);
}
}
bool solve_component()
{
for (int i = 0; i < comp.size(); i ++)
for (int j = 0; j < comp.size(); j ++)
if (cap[comp[i]][comp[j]] == 0)
return false;
for (int i = 0; i < (int)(comp.size()) - 1; i ++)
{
answer[comp[i]][comp[i + 1]] = 1;
answer[comp[i + 1]][comp[i]] = 1;
}
if (comp.size() != 1)
{
if (cap[comp[0]][comp[1]] == 2)
{
answer[comp[0]][comp.back()] = 1;
answer[comp.back()][comp[0]] = 1;
}
}
return true;
}
int construct(std::vector<std::vector<int>> p) {
int n = p.size();
for (int i = 0; i < n; i++) {
std::vector<int> row;
row.resize(n, 0);
answer.push_back(row);
}
for (int i = 0; i < n; i ++)
for (int j = 0; j < n; j ++)
cap[i][j] = p[i][j];
for (int i = 0; i < n; i ++)
for (int j = 0; j < n; j ++)
{
if (i != j && p[i][j] != 0)
graph[i].push_back(j);
}
for (int i = 0; i < n; i ++)
{
if (!used[i])
{
comp.clear();
dfs(i);
bool is_fine = solve_component();
if (!is_fine)
return 0;
}
}
build(answer);
return 1;
}
컴파일 시 표준 에러 (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... |