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;
typedef pair<int,int> pii;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
vector<int> vis, block, at;
vector<vector<pii>> edges;
vector<int> dfs(int x) {
vis[x] = 1;
for(auto [viz,ind] : edges[x]) {
if(block[viz]) continue;
if(vis[viz]) {
at.pb(ind);
return at;
}
at.pb(ind);
vector<int> v = dfs(viz);
if(!v.empty()) return v;
}
block[x] = 1;
return {};
}
variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) {
edges.resize(N);
vis.resize(N);
block.resize(N);
for(int i = 0; i < M; i += 2) edges[U[i]].pb({V[i], i});
vector<int> c = dfs(0);
if(c.empty()) return false;
return true;
}
# | 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... |