Submission #1074362

#TimeUsernameProblemLanguageResultExecution timeMemory
1074362ZicrusThousands Islands (IOI22_islands)C++17
0 / 100
2 ms604 KiB
#include <bits/stdc++.h> #include "islands.h" using namespace std; typedef long long ll; int n, m; vector<vector<pair<int, int>>> adj, revAdj; // edgeId, node vector<bool> vst; unordered_multiset<ll> has; bool poss(int cur) { if (vst[cur]) return false; vst[cur] = true; int cnt = 0; for (auto &e : adj[cur]) { ll hash = ((ll)min(cur, e.second) << 31) | max(cur, e.second); if (!has.count(hash)) continue; has.erase(hash); if (poss(e.second)) return true; cnt++; } return cnt >= 2; } variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) { n = N; m = M; adj = vector<vector<pair<int, int>>>(n); for (int i = 0; i < m; i++) { adj[U[i]].push_back({i, V[i]}); if (U[i] < V[i]) { ll hash = ((ll)U[i] << 31) | V[i]; has.insert(hash); } } vst = vector<bool>(n); return poss(0); } #ifdef TEST #include "grader.cpp" #endif
#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...