# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
350805 | juggernaut | Stations (IOI20_stations) | C++14 | 1071 ms | 1292 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;
#ifndef EVAL
#include"stub.cpp"
#endif
vector<int>gr[1005];
vector<int>order;
int tiktak;
int tin[1005],tout[1005];
void dfs(int v,int p=-1,bool h=0){
if(!h){
tin[v]=tiktak++;
order[v]=tin[v];
}
for(int to:gr[v]){
if(to==p)continue;
dfs(to,v,h^1);
}
if(h){
tout[v]=tiktak++;
order[v]=tout[v];
}
}
vector<int>label(int n,int k,vector<int>u,vector<int>v){
order.resize(n);
for(int i=0;i<n-1;i++){
gr[u[i]].push_back(v[i]);
gr[v[i]].push_back(u[i]);
}
dfs(0);
for(int i=0;i<n;i++)gr[i].clear();
tiktak=0;
return order;
}
int find_next_station(int s,int t,vector<int>c){
if(c.size()==1)return c[0];
int x,y;
if(s<c[0]){//tin[v]
x=s;
if(s==0)y=c[c.size()-1];
else y=c[c.size()-2];
if(t<x||t>y)return c.back();
for(int i=0;i<c.size();i++)if(t<=c[i])return c[i];
}else{//tout[s]
x=c[1]-1;
if(t<x||t>s)return c[0];
for(int i=c.size()-1;i>=1;i--)if(c[i]<=t)return c[i];
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |