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 <bits/stdc++.h>
using namespace std;
variant<bool, vector<int>> find_journey(int N,int M,vector<int> U,vector<int> V){
vector<vector<int>> adj(N);
for(int i=0;i<M;i++) {
adj[U[i]].emplace_back(V[i]);
}
vector<int> visited(N);
bool found = false;
for(int&child:adj[0]) {
bool works = false;
function<void(int)> dfs = [&](int x) {
if(visited[x]==2)return;
if(visited[x]==1) {
works = true;
return;
}
visited[x]=1;
for(int&i:adj[x])dfs(i);
visited[x]=2;
};
dfs(child);
if(!works)continue;
visited = vector<int>(N);
if(found)return true;
found = true;
}
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... |