This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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> path, vis(N, 0);
path.push_back(0);
while(path.size()){
vis[path.back()] = true;
if(tree[path.back()].size()){
int a = tree[path.back()].front();
tree[path.back()].pop();
path.push_back(a);
if(vis[path.back()])break;
}
else{
vis[path.back()] = false;
path.pop_back();
}
}
if(path.size()){
return path;
}
return false;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |