제출 #830614

#제출 시각아이디문제언어결과실행 시간메모리
830614caganyanmaz수천개의 섬 (IOI22_islands)C++17
22.75 / 100
30 ms8928 KiB
#include <bits/stdc++.h> #define mp(x...) array<int, 2>({x}) #define pb push_back #include "islands.h" using namespace std; //#include "../debug.h" #define debug(x...) void(42) int n, m; vector<int> u, v; variant<bool, vector<int>> subtask1() { if (n <= 2) return false; array<array<int, 3>, 3> a; for (int i = 0; i < m; i++) if (u[i] <= 2 && v[i] <= 2) a[u[i]][v[i]] = i; debug(a); return vector<int>({a[0][1], a[1][2], a[2][0], a[0][2], a[2][1], a[1][0], a[2][0], a[1][2], a[0][1], a[1][0], a[2][1], a[0][2]}); } constexpr static int MXN = 1e5; bitset<MXN> visited; vector<array<int, 2>> g[MXN]; vector<int> res; bool dfs(int node, int le) { visited[node] = true; debug(node, g[node]); if (g[node].size() > 2 || (g[node].size() > 1 && le < 0)) { for (auto [c,e] : g[node]) { if (e/2 == le/2) continue; res.pb(e); res.pb(e^1); } for (auto [c, e] : g[node]) { if (e/2 == le/2) continue; res.pb(e^1); res.pb(e); } return true; } for (auto [c, e] : g[node]) { debug(node, c, e, le); if (!visited[c]) { res.pb(e); if (dfs(c, e)) { res.pb(e); return true; } res.pop_back(); } } return false; } static inline int get_reverse(int i) { return (i / 2) * 2 + 1 - (i&1); } variant<bool, vector<int>> subtask2() { for (int i = 0; i < m; i++) { g[u[i]].pb(mp(v[i], i)); debug(i, u[i], v[i]); } if (dfs(0, -5)) return res; return false; } variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) { n = N; m = M; u = U; v = V; return subtask2(); assert(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...