# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
305089 | Theo830 | Stations (IOI20_stations) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
#define f(i,a,b) for(ll i = a;i < b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vll vector<ll>
#define pb push_back
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Training
bool isin(ll l,ll r,ll x){
return (l <= x && x <= r);
}
int find_next_station(int s,int t,vector<int> c){
ll tins,touts;
if(s < c[0]){
tins = s;
touts = c.back();
if(!isin(tins,touts,t)){
return c.back();
}
else{
for(auto x:c){
if(t <= x){
return x;
}
}
}
}
else{
touts = s;
tins = c[0];
if(!isin(tins,touts,t)){
return c[0];
}
else{
reverse(c.begin(),c.end());
for(auto x:c){
if(x <= t){
return x;
}
}
}
}
assert(0);
}