Submission #633666

#TimeUsernameProblemLanguageResultExecution timeMemory
633666flappybirdThousands Islands (IOI22_islands)C++17
1.75 / 100
41 ms14752 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; #define MAX 201010 int deg[MAX]; vector<int> adj[MAX]; vector<int> radj[MAX]; int chk[MAX]; int N, M; variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) { int i; ::N = N; ::M = M; for (i = 0; i < M; i++) deg[U[i]]++, adj[U[i]].push_back(i), radj[V[i]].push_back(U[i]); queue<int> q; for (i = 0; i < N; i++) if (!deg[i]) q.push(i); int s = 0; vector<int> st; while (deg[s] <= 1) { if (deg[s] == 0) return false; for (auto n : adj[s]) { if (!chk[V[n]]) { for (auto v : radj[s]) if (!chk[v]) { deg[v]--; chk[v] = 1; if (deg[v] == 0) q.push(v); } s = V[n]; st.push_back(n); break; } } } while (q.size()) { int t = q.front(); q.pop(); for (auto v : radj[t]) if (!chk[v]) { deg[v]--; chk[v] = 1; if (deg[v] == 0) q.push(v); } while (deg[s] <= 1) { if (deg[s] == 0) return false; for (auto n : adj[s]) { if (!chk[V[n]]) { for (auto v : radj[s]) if (!chk[v]) { deg[v]--; chk[v] = 1; if (deg[v] == 0) q.push(v); } s = V[n]; st.push_back(n); break; } } } } return vector<int>(1, 2); vector<int> ans = st; int a, b; a = b = -1; for (auto n : adj[s]) if (!chk[V[n]]) b = a, a = n; }
#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...