제출 #926156

#제출 시각아이디문제언어결과실행 시간메모리
926156winter0101기지국 (IOI20_stations)C++14
13 / 100
591 ms1172 KiB
#include<bits/stdc++.h> using namespace std; #define all(fl) fl.begin(),fl.end() #define pb push_back #define fi first #define se second #define for1(i,j,k) for(int i=j;i<=k;i++) #define for2(i,j,k) for(int i=j;i>=k;i--) #define for3(i,j,k,l) for(int i=j;i<=k;i+=l) #define lb lower_bound #define ub upper_bound #define sz(a) (int)a.size() #define pii pair<int,int> #define pli pair<long long,int> #define gcd __gcd #define lcm(x,y) x*y/__gcd(x,y) const int maxn=1e3+9; vector<int>a[maxn],in,dep; int tme=0; void dfs(int u,int par){ if (dep[u]%2==0)in[u]=++tme; for (auto v:a[u]){ if (v==par)continue; dep[v]=dep[u]+1; dfs(v,u); } if (dep[u]%2==1)in[u]=++tme; in[u]--; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { for1(i,0,n-1)a[i].clear(); for1(i,0,n-2)a[u[i]].pb(v[i]),a[v[i]].pb(u[i]); in.resize(n),dep.resize(n); tme=0; dfs(0,0); return in; } int find_next_station(int s, int t, std::vector<int> c) { if (sz(c)==1)return c[0]; if (s>c[0]){//dep 1 if (t>=c[1]&&t<=s){ for1(i,0,sz(c)-2){ if (t>=c[i]&&t<=c[i+1]-1)return c[i]; } return c.back(); } else return c[0]; } else {//dep 0 if (s==0){ for1(i,sz(c)-1,1){ if (c[i-1]+1<=t&&t<=c[i])return c[i]; } return c[0]; } if (t>=s&&t<=c[sz(c)-2]){ for1(i,sz(c)-2,1){ if (c[i-1]+1<=t&&t<=c[i])return c[i]; } return c[0]; } else { 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...