Submission #628176

#TimeUsernameProblemLanguageResultExecution timeMemory
628176TurkhuuThousands Islands (IOI22_islands)C++17
8.40 / 100
40 ms6096 KiB
#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 (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 < s; i++) { for (int j = 0; j < s; j++) { ans.push_back(c[(s - i + j) % s]); } for (int j = 0; j < s; j++) { ans.push_back(c[(s - i + j) % s] ^ 1); } } for (int i = 0; i < a.size(); i++) { ans.push_back(a[i]); }*/ R[A] = 2; return true; } if (R[B] == 0) { if (dfs(B)) { R[A] = 2; return true; } } } R[A] = 2; return false; }; E[0] = -2; if (dfs(0)) { return ans; } else { return false; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...