Submission #633668

#TimeUsernameProblemLanguageResultExecution timeMemory
633668flappybirdThousands Islands (IOI22_islands)C++17
11.90 / 100
55 ms15680 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 (1) { while (q.size()) { int t = q.front(); chk[t] = 1; q.pop(); for (auto v : radj[t]) if (!chk[v]) { deg[v]--; if (deg[v] == 0) q.push(v); } } if (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]--; if (deg[v] == 0) q.push(v); } s = V[n]; st.push_back(n); break; } } } if (deg[s] == 0) return false; if (deg[s] <= 1 || q.size()) continue; else 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...