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;
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
const ll maxn = 100005;
vector<int> edges[maxn];
bool visited[maxn];
bool flag = 0;
void dfs(ll a){
visited[a] = 1;
for (auto&i : edges[a]){
if (visited[i]) flag = 1;
else{
visited[i] = 1;
dfs(i);
}
}
}
std::variant<bool, std::vector<int>> find_journey(
int N, int M, std::vector<int> U, std::vector<int> V) {
FOR(i,0,maxn) visited[i] = 0;
FOR(i,0,M){
edges[U[i]].push_back(V[i]);
}
dfs(0);
if (flag==1) return vector<int>{1};
else 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... |