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;
vector<vector<pair<int, int>>> adj;
vector<int> res, visited;
bool ok;
void DFS(int index)
{
visited[index] = 1;
for (auto node : adj[index])
{
if (visited[node.first])
{
ok = true;
return;
}
DFS(node.first);
}
}
variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V)
{
adj = vector<vector<pair<int, int>>>(N);
res = vector<int>();
set<pair<int, int>> s;
for (int i = 0; i < M; i += 2)
{
if (s.count({U[i], V[i]})) continue;
adj[U[i]].push_back({V[i], i});
s.insert({U[i], V[i]});
}
ok = false;
visited = vector<int>(N);
DFS(0);
if (ok)
return vector<int>({0});
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... |