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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 2e5 + 100;
int n;
vector<pii> g[maxn];
int used[maxn];
bool dfs(int v, int i){
used[v] = 1;
for(auto [to, in]: g[v]){
if(in == i) continue;
if(used[to]) return 1;
if(dfs(to, in)) return 1;
} return 0;
}
std::variant<bool, std::vector<int>> find_journey(
int N, int M, std::vector<int> U, std::vector<int> V){
n = N;
for(int i = 0; i < M; i++){
int a = U[i] + 1, b = V[i] + 1;
g[a].push_back({b, i / 2});
}
return dfs(1, -1);
}
# | 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... |