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>
#define ll long long
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
namespace
{
int K;
vector<int> path;
int vis[100000], use[200000], p[100000], pe[100000], deg[100000];
vector<pii> E[100000];
void dfs(int u)
{
vis[u] = 1;
for (auto [v, i] : E[u])
if (vis[v] == 0)
{
p[v] = u;
pe[v] = i;
dfs(v);
deg[u]++;
}
else if (vis[v] == 1 && v != p[u])
use[i] = 1;
}
}
variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V)
{
for (int i = 0; i < M; i++)
if (U[i] < V[i])
{
E[U[i]].emplace_back(pii(V[i], i));
E[V[i]].emplace_back(pii(U[i], i));
}
dfs(0);
if(*max_element(deg, deg + N) >= 2)
return true;
if(*max_element(use, use + M) >= 1)
return true;
return false;
}
Compilation message (stderr)
islands.cpp:11:9: warning: '{anonymous}::K' defined but not used [-Wunused-variable]
11 | int K;
| ^
# | 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... |