이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "islands.h"
#include <bits/stdc++.h>
using namespace std;
variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) {
vector<vector<pair<int, int>>> G(N);
for (int i = 0; i < M; i++) {
G[U[i]].emplace_back(V[i], i);
}
vector<int> E(N, -1), ans, R(N);
function<bool(int)> dfs = [&](int A) {
R[A] = 1;
for (auto [B, C] : G[A]) {
if (E[A] != (C ^ 1)) {
if (R[B] == 1) {
vector<int> a;
int F = B;
while (F != 0) {
a.push_back(E[F]);
F = U[E[F]];
}
vector<int> c;
int D = A;
while (D != B) {
c.push_back(E[D]);
D = U[E[D]];
}
reverse(c.begin(), c.end());
c.push_back(C);
int s = c.size();
for (int i = a.size() - 1; i >= 0; i--) {
ans.push_back(a[i]);
}
for (int i = 0; i < c.size(); i++) {
ans.push_back(c[i]);
}
ans.push_back(c[0] ^ 1);
ans.push_back(c[0]);
for (int i = c.size() - 1; i > 0; i--) {
ans.push_back(c[i]);
}
ans.push_back(c[0] ^ 1);
for (int i = 0; i < a.size(); i++) {
ans.push_back(a[i]);
}
return true;
}
if (R[B] == 0) {
E[B] = C;
if (dfs(B)) {
return true;
}
}
}
}
R[A] = 2;
return false;
};
E[0] = -2;
if (dfs(0)) {
return ans;
} else {
return false;
}
}
컴파일 시 표준 에러 (stderr) 메시지
islands.cpp: In lambda function:
islands.cpp:33:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int i = 0; i < c.size(); i++) {
| ~~^~~~~~~~~~
islands.cpp:42:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for (int i = 0; i < a.size(); i++) {
| ~~^~~~~~~~~~
islands.cpp:29:15: warning: unused variable 's' [-Wunused-variable]
29 | int s = c.size();
| ^
# | 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... |