제출 #1024520

#제출 시각아이디문제언어결과실행 시간메모리
1024520mansur수천개의 섬 (IOI22_islands)C++17
1.75 / 100
24 ms15756 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; int is = 0; void dfs(int u, int x) { was[u] = 1; for (auto [to, id]: g[u]) { if (id == x) { is = 1; continue; } if (!was[to]) { pr[to] = {u, id}; dfs(to, x); if (sz(s)) return; }else if (!to) { s.push_back(id); while (u) { s.push_back(pr[u].s); u = pr[u].f; } return; } } } variant<bool, vector<int>> find_journey(int n, int m, vector<int> u, vector<int> v) { for (int i = 0; i < m; i++) g[u[i]].push_back({v[i], i}); int cnt = 0; for (auto [to, id]: g[0]) { was[0] = 1; is = 0; dfs(to, id ^ 1); if (is) cnt++; if (sz(s)) return true; for (int i = 0; i < n; i++) { was[i] = 0; } } return cnt > 1; 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...