Submission #372919

#TimeUsernameProblemLanguageResultExecution timeMemory
372919Jarif_RahmanStations (IOI20_stations)C++17
0 / 100
5 ms1388 KiB
#include "stations.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; struct graph{ int n; vector<vector<int>> v; graph(){} graph(int nn, vector<int> aa, vector<int> bb){ n = nn; v.assign(n, {}); for(int i = 0; i < n-1; i++){ v[aa[i]].pb(bb[i]); v[bb[i]].pb(aa[i]); } } }; int r = 0, rr = 0; vector<graph> g(10); vector<int> gg; vector<int> label(int n, int k, vector<int> aa, vector<int> bb){ g[r++] = graph(n, aa, bb); vector<int> lb(n); for(int i = 0; i < n; i++) lb[i] = rr++; gg.pb(rr); return lb; } vector<int> cur; int ans; void dfs(int nd, int ss, int tt, graph gr){ if(nd == tt){ ans = cur.front(); return; } if(ans != -1) return; for(int x: gr.v[nd]) if(x!=ss){ cur.pb(x); dfs(x, nd, tt, gr); cur.pop_back(); } } int find_next_station(int s, int t, vector<int> c){ cur.clear(); ans = -1; int gi = upper_bound(gg.begin(), gg.end(), s) - gg.begin(); dfs(s, -1, t, g[gi]); return ans; }
#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...