제출 #1039216

#제출 시각아이디문제언어결과실행 시간메모리
1039216Dan4Life기지국 (IOI20_stations)C++17
0 / 100
614 ms912 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; int dfs_timer = 0; vi labels, adj[mxN]; void dfs(int s, int p){ for(auto u : adj[s]) if(u!=p) dfs(u,s); labels[s] = dfs_timer++; } 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(sz(c)==1) return c[0]; for(auto u : c) if(u==t) return u; if(t>s) return c.back(); bool isRoot = (c.back()<=s); for(int i = 0; i < sz(c)-2+isRoot; i++) if(c[i] < t and t < c[i+1]) return c[i+1]; if(isRoot) return c[0]; int sub0 = s-1-c[0]; if(c[0]-sub0+1 <= t and t < c[0]) return c[0]; return c.back(); }
#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...