제출 #1039888

#제출 시각아이디문제언어결과실행 시간메모리
1039888Dan4Life기지국 (IOI20_stations)C++17
76 / 100
557 ms1188 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, int dep){ if(!dep) labels[s] = dfs_timer; dfs_timer++; for(auto u : adj[s]) if(u!=p) dfs(u,s,dep^1); if(dep) labels[s] = dfs_timer; 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, 0); vi lol; lol.clear(); for(auto u : labels) lol.pb(u); 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(s < c[0]){ if(!s or (s<=t and t<=end(c)[-2]+1)){ for(int i = 1; i < sz(c)-!!s; i++) if(c[i-1]+1<=t and t<=c[i]) return c[i]; return c[0]; } return c.back(); } if(c[1]-1<=t and t<=s){ for(int i = 1; i < sz(c)-1; i++) if(c[i]<=t and t<=c[i+1]-1) return c[i]; return c.back(); } 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...