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>
#include <variant>
#include <vector>
using namespace std;
int ind[300005];
int ph[1005][1005];
vector<int> vv[300005];
bool can[300005];
void dfs(int now,int fa)
{
can[now] = true;
for(int i=0;i<vv[now].size();i++)
{
int go = vv[now][i];
if(can[go] == false)dfs(go,now);
}
}
std::variant<bool, std::vector<int>> find_journey(
int N, int M, std::vector<int> U, std::vector<int> V) {
for(int i=0;i<M;i++)
{
vv[U[i]].push_back(V[i]);
ind[U[i]]++;
ind[V[i]]++;
}
dfs(0,-1);
if(ind[0] >= 2)return true;
for(int i=1;i<N;i++)
{
if(ind[i] >= 3 && can[i] == true)return true;
}
/*
if (N == 4) {
return std::vector<int>({0, 1, 2, 4, 0, 3, 2, 1, 4, 3});
}
return false;*/
return false;
}
Compilation message (stderr)
islands.cpp: In function 'void dfs(int, int)':
islands.cpp:13:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for(int i=0;i<vv[now].size();i++)
| ~^~~~~~~~~~~~~~~
# | 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... |