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;
#define pb push_back
template <class F, class S>
bool chmin(F &u, const S &v){
bool flag = false;
if ( u > v ){
u = v; flag |= true;
}
return flag;
}
std::variant<bool, std::vector<int>> find_journey(
int N, int M, std::vector<int> U, std::vector<int> V) {
int n = N, m = M;
// subtask #3
vector <vector<int>> adj(n);
for ( int i = 0; i < m; i++ ){
adj[U[i]].pb(V[i]);
}
vector <int> d(n, n + 1);
queue <int> q;
q.push(0); d[0] = 0;
while ( !q.empty() ){
int u = q.front();
q.pop();
for ( auto &v: adj[u] ){
if ( chmin(d[v], d[u] + 1) ){
q.push(v);
}
}
}
set <int> st;
for ( auto &x: st ) st.insert(x);
return (int)st.size() != n;
}
# | 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... |