Submission #1024511

#TimeUsernameProblemLanguageResultExecution timeMemory
1024511mansurThousands Islands (IOI22_islands)C++17
1.75 / 100
20 ms14552 KiB
#include "islands.h" #include <bits/stdc++.h> #include <variant> using namespace std; #define rall(s) s.rbegin(), s.rend() #define all(s) s.begin(), s.end() #define sz(s) (int) s.size() #define s second #define f first using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int N = 3e5; vector<pii> g[N], pr(N); vector<int> was(N), s; void dfs(int u) { was[u] = 2; for (auto [to, id]: g[u]) { if (!was[to]) { pr[to] = {u, id}; dfs(to); if (sz(s)) return; }else if (!to) { s.push_back(id); while (u) { s.push_back(pr[u].s); u = pr[u].f; } return; } } was[u] = 1; } variant<bool, vector<int>> find_journey(int n, int m, vector<int> u, vector<int> v) { if (n == 2) return false; return true; for (int i = 0; i < m; i++) g[u[i]].push_back({v[i], i}); dfs(0); if (!sz(s)) return false; return true; reverse(all(s)); vector<int> ans; for (int x: s) ans.push_back(x); }
#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...