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;
bool ok;
void DFS(int index, int last)
{
if (adj[index].size() > 2)
{
ok = true;
return;
}
for (auto node : adj[index])
{
if (node.first == last) continue;
res.push_back(node.second);
DFS(node.first, index);
break;
}
}
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>();
for (int i = 0; i < M; i++)
{
adj[U[i]].push_back({V[i], i});
}
if (adj[0].size() > 1)
{
int s_out = adj[0][0].second;
int s_in = s_out^1;
int e_out = adj[0][1].second;
int e_in = e_out^1;
return vector<int>({s_out, s_in, e_out, e_in, s_in, s_out, e_in, e_out});
}
ok = false;
DFS(0, -1);
if (ok)
return vector<int>({99});
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... |