Submission #628577

#TimeUsernameProblemLanguageResultExecution timeMemory
628577c28dnv9q3Thousands Islands (IOI22_islands)C++17
9.10 / 100
31 ms5580 KiB
#include "islands.h" #include <variant> #include <vector> #include <map> #include <queue> using namespace std; vector<int> U, V; int N, M; vector<vector<int>> adj; bool path_exists(int target) { vector<bool> vis(N); queue<int> q; q.push(0); vis[0] = true; while (!q.empty()) { int x = q.front(); q.pop(); if (x == target) return true; for (auto c : adj[x]) { if (!vis[V[c]]) { vis[V[c]] = true; q.push(V[c]); } } } return false; } variant<bool, vector<int>> find_journey( int N, int M, vector<int> U, vector<int> V) { ::U = U; ::V = V; ::N = N; ::M = M; adj.resize(N); for (int i = 0; i < M; i++) adj[U[i]].push_back(i); if (adj[0].size() >= 2) return true; for (int i = 0; i < N; i++) { if (adj[i].size() >= 3 && path_exists(i)) return true; } return 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...