이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "islands.h"
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
using namespace std;
using ll = long long;
template<class T, class U> bool chmin(T& a, const U& b) { return a > b ? a = b, true : false; }
template<class T, class U> bool chmax(T& a, const U& b) { return a < b ? a = b, true : false; }
struct edge {
int to, idx;
};
using Graph = vector<vector<edge>>;
std::variant<bool, std::vector<int>> find_journey(int N, int M, std::vector<int> U, std::vector<int> V) {
Graph G(N);
rep (i, M) {
G[U[i]].push_back({V[i], i});
}
vector<int> memo;
int cur = 0;
while (1) {
vector<edge> nxts;
for (auto e : G[cur]) {
if (memo.empty() || e.idx / 2 != memo.back() / 2) nxts.push_back(e);
}
if (nxts.size() == 0) return false;
if (nxts.size() >= 2) {
vector<int> ans;
rep (i, memo.size()) ans.push_back(memo[i]);
ans.push_back(nxts[0].idx);
ans.push_back(nxts[0].idx ^ 1);
ans.push_back(nxts[1].idx);
ans.push_back(nxts[1].idx ^ 1);
ans.push_back(nxts[0].idx ^ 1);
ans.push_back(nxts[0].idx);
ans.push_back(nxts[1].idx ^ 1);
ans.push_back(nxts[1].idx);
rrep (i, memo.size()) ans.push_back(memo[i]);
return ans;
}
memo.push_back(nxts[0].idx);
cur = nxts[0].to;
}
return false;
}
# | 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... |