Submission #836301

#TimeUsernameProblemLanguageResultExecution timeMemory
836301ALeonidouThousands Islands (IOI22_islands)C++17
6.75 / 100
27 ms4656 KiB
#include "islands.h" #include <variant> #include <bits/stdc++.h> using namespace std; #define ll int #define sz(x) (ll)x.size() #define F first #define S second #define MID ((l+r)/2) #define pb push_back #define dbg(x) cout<<#x<<": "<<x<<endl; #define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl; #define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl; #define dbg4(x,y,z,w) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<" "<<#w<<": "<<w<<endl; #define dbg5(x,y,z,w,q) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<" "<<#w<<": "<<w<<" "<<#q<<": "<<q<<endl; typedef vector <ll> vi; typedef pair <ll,ll> ii; typedef vector <ii> vii; #define MOD 1000002022 #define inf 1e9 vector <vi> adj; vi vis; bool dfs(ll u, ll p){ if (u == 0) return true; vis[u] = 1; for (ll i=0; i<sz(adj[u]); i++){ if (adj[u][i] != p && !vis[adj[u][i]]){ if (dfs(adj[u][i], u)) return true; } } return false; } variant<bool, vi> find_journey(int N, int M, vi U, vi V){ ll n = N, m = M; vi a, b; if (n == 2){ for (ll i =0; i<m; i++){ if (U[i] == 0) a.pb(i); else b.pb(i); } bool ok = (sz(a) >= 2 && sz(b) >= 1); vi v(6); if (ok){ vi v(6); ll x = a[0], y = b[0], z = a[1]; v[0] = x, v[1] = y, v[2] = z; v[3] = x, v[4] = y, v[5] = z; return v; } return false; } else{ //SUBTASK 3 adj.assign(n, vi()); for (ll i=0; i<m;i++){ adj[U[i]].pb(V[i]); } vis.assign(n, 0); bool ok = false; for (ll i=0; i<sz(adj[0]); i++){ ok = dfs(adj[0][i], 0); if (ok) break; } if (ok) return vi(); else return false; } }
#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...