Submission #825481

#TimeUsernameProblemLanguageResultExecution timeMemory
825481LiudasThousands Islands (IOI22_islands)C++17
10.15 / 100
31 ms4560 KiB
#include "islands.h" #include <cassert> #include <fstream> #include <cstdio> #include <variant> #include <vector> #include <map> #include <set> #include <queue> #include <unordered_set> #include <algorithm> #include <iostream> using namespace std; variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) { vector<queue<int>> tree(N); for(int i = 0; i < M; i ++){ tree[U[i]].push(V[i]); } vector<int> path1, path2, vis(N, 0); path1.push_back(0); while(path1.size()){ vis[path1.back()] = true; if(tree[path1.back()].size()){ int a = tree[path1.back()].front(); tree[path1.back()].pop(); path1.push_back(a); if(vis[path1.back()])break; } else{ vis[path1.back()] = false; path1.pop_back(); } } for(int i : path1){ path2.push_back(i); while(path2.size()){ vis[path2.back()] = true; if(tree[path2.back()].size()){ int a = tree[path2.back()].front(); tree[path2.back()].pop(); path2.push_back(a); if(vis[path2.back()])break; } else{ vis[path2.back()] = false; path2.pop_back(); } } vis[i] = true; if(path2.size())break; } if(path1.size() && path2.size()){ return path1; } 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...