| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 603716 | CyberCow | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 0 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <vector>
#include <queue>
#include <unordered_set>
using namespace std;
vector<pair<int, int>> g[1005];
vector<int> a, gt;
int qaq = 1;
void Dfs1(int ga)
{
gt.push_back(ga);
a[ga] = 1;
for (pair<int, int> to : g[ga])
{
if (a[to.first] == 0 && to.second == 1)
{
Dfs1(to.first);
}
}
}
void Dfs2(int ga)
{
a[ga] = qaq;
for (auto to : g[ga])
{
if (to.second == 1 && a[to.first] == qaq)
return;
}
gt.push_back(ga);
for (auto to : g[ga])
{
if (a[to.first] == 0 && to.second == 2)
Dfs2(to.first);
}
}
int construct(vector<vector<int>> p) {
int n = p.size();
vector<vector<int>> ans(n,vector<int>(n));
int i, j;
for (i = 0; i < n; i++)
{
for ( j = 0; j < n; j++)
{
if (i != j && p[i][j] != 0)
{
g[i].push_back({ j, p[i][j] });
}
}
}
for ( i = 0; i < n; i++)
{
a.push_back(0);
}
for ( i = 0; i < n; i++)
{
if (a[i] == 0 && g[i].size())
{
Dfs1(i);
for ( j = 0; j < gt.size() - 1; j++)
{
ans[gt[j]][gt[j + 1]] = 1;
ans[gt[j + 1]][gt[j]] = 1;
}
gt.clear();
}
}
for ( i = 0; i < n; i++)
{
a[i] = 0;
}
for ( i = 0; i < n; i++)
{
if (a[i] == 0 && g[i].size())
{
Dfs2(i);
if (gt.size())
for (j = 0; j < gt.size(); j++)
{
ans[gt[j]][gt[(j + 1) % gt.size()]] = 1;
ans[gt[(j + 1) % gt.size()]][gt[j]] = 1;
}
gt.clear();
qaq++;
}
}
build(ans);
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... | ||||
