| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 787562 | thimote75 | 수천개의 섬 (IOI22_islands) | C++17 | 33 ms | 6336 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "islands.h"
#include <bits/stdc++.h>
using namespace std;
using idata = vector<int>;
using igrid = vector<idata>;
using bdata = vector<bool>;
igrid roads;
bdata visited;
bdata visiting;
idata path;
bool dfs (int node) {
if (visiting[node]) {
path.push_back(node);
return true;
}
if (visited[node]) return false;
path.push_back(node);
visited[node] = true;
visiting[node] = true;
for (int next : roads[node]) if (dfs(next))
return true;
visiting[node] = false;
path.pop_back();
return false;
}
std::variant<bool, idata> find_journey(
int N, int M, idata U, idata V) {
roads.resize(N);
visited.resize(N); visiting.resize(N);
bool st3 = M % 2 == 0;
for (int i = 0; i < M; i ++)
roads[U[i]].push_back(V[i]);
for (int i = 0; i + 1 < M; i += 2)
st3 &= (U[i] == U[i + 1]) && (V[i] == V[i + 1]);
if (!dfs(0)) return false;
idata dpath;
idata cycle;
int joint = path[path.size() - 1];
bool f_joint = false;
for (int i = 0; i + 1 < path.size(); i ++) {
if (f_joint) cycle.push_back(path[i]);
else if (path[i] != joint) dpath.push_back(path[i]);
f_joint |= path[i] == joint;
}
idata answer;
if (st3) { // dpath + (joint + cycle) * 2 + (joint + cycle^-1) * 2 + joint + dpath^-1
for (int u : dpath) answer.push_back(u);
answer.push_back(joint);
for (int u : cycle) answer.push_back(u);
answer.push_back(joint);
for (int u : cycle) answer.push_back(u);
reverse(cycle.begin(), cycle.end());
answer.push_back(joint);
for (int u : cycle) answer.push_back(u);
answer.push_back(joint);
for (int u : cycle) answer.push_back(u);
answer.push_back(joint);
reverse(dpath.begin(), dpath.end());
for (int u : dpath) answer.push_back(u);
}
return answer;
}
컴파일 시 표준 에러 (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... | ||||
