Submission #1042487

#TimeUsernameProblemLanguageResultExecution timeMemory
1042487Alihan_8Thousands Islands (IOI22_islands)C++17
0 / 100
16 ms4188 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...