Submission #793282

#TimeUsernameProblemLanguageResultExecution timeMemory
793282MODDIStations (IOI20_stations)C++17
0 / 100
604 ms660 KiB
#include <bits/stdc++.h> #include "stations.h" using namespace std; #define pb push_back #define mp make_pair typedef long long ll; int cnt; vector<int> G[1001], labels; void dfs(int at, int p, int d){ if(!d) labels[at] = cnt++; for(auto next : G[at]){ if(next != p) dfs(next, at, d^1); } if(d) labels[at] = cnt++; } vector<int> label(int n, int k, vector<int> u, vector<int> v){ cnt = 0; for(int i = 0; i < n; i++){ G[i].clear(); } for(int i = 0; i < n - 1; i++){ G[u[i]].pb(v[i]); G[v[i]].pb(u[i]); } labels.resize(n); dfs(0, -1, 0); return labels; } int find_next_station(int s, int t, vector<int> c){ if(s < c[0]){ if(t < s || t >= c.back()) return c.back(); return *lower_bound(c.begin(), c.end(), t); } if(t > s || t <= c[0]) return c[0]; return *--lower_bound(c.begin(), c.end(), t); }
#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...