Submission #1074429

#TimeUsernameProblemLanguageResultExecution timeMemory
1074429fv3Thousands Islands (IOI22_islands)C++17
8.40 / 100
79 ms10324 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; vector<vector<pair<int, int>>> adj; vector<int> res, visited; bool ok; void DFS(int index, set<int>&path) { visited[index] = 1; path.insert(index); for (auto node : adj[index]) { if (path.count(node.first)) { ok = true; return; } if (visited[node.first]) continue; DFS(node.first, path); } path.erase(index); } variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) { adj = vector<vector<pair<int, int>>>(N); res = vector<int>(); set<pair<int, int>> s; for (int i = 0; i < M; i += 2) { if (s.count({U[i], V[i]})) continue; adj[U[i]].push_back({V[i], i}); s.insert({U[i], V[i]}); } ok = false; visited = vector<int>(N); set<int> path; DFS(0, path); if (ok) return vector<int>({0}); 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...