Submission #1039135

#TimeUsernameProblemLanguageResultExecution timeMemory
1039135Dan4LifeStations (IOI20_stations)C++17
0 / 100
569 ms900 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a),end(a) using ll = long long; using vi = vector<int>; const int mxN = 1010; vi labels; int dfs_timer = 0; vi adj[mxN]; void dfs(int s, int p){ labels[s] = dfs_timer++; for(auto u : adj[s]) if(u!=p) dfs(u,s); } vi label(int n, int k, vi u, vi v) { labels.clear(); labels.resize(n,0); dfs_timer=0; for(int i = 0; i < n; i++) adj[i].clear(); for(int i = 0; i < sz(u); i++){ int a = u[i], b = v[i]; adj[a].pb(b), adj[b].pb(a); } dfs(0,-1); return labels; } int find_next_station(int s, int t, vi c) { if(t < s) return c[0]; int pos = lower_bound(all(c),t)-begin(c)-1; if(pos!=-1 and pos!=sz(c)) return c[pos]; return c[0]; }
#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...