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 <variant>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int n,m;
vector<vector<int>> adj;
vector<int> visited;
void dfs(int v) {
visited[v]++;
for (auto u: adj[v]) {
if (!visited[u]) {
dfs(u);
} else {
visited[u]++;
}
}
}
variant<bool, vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) {
n = N; m = M; adj.resize(n); visited.resize(n,0);
for (int i=0;i<m;i++) {
adj[U[i]].push_back(V[i]);
}
dfs(0);
int ans = 0;
for (auto u: visited) {
ans += max(0,u-1);
}
if (ans >= 2) {
return true;
} else {
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... |