# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
986583 | CSQ31 | Stations (IOI20_stations) | C++17 | 583 ms | 1700 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;
vector<int>adj[1000];
int tin[1000],tout[1000];
int timer = -1;
void dfs(int v,int u){
tin[v] = ++timer;
for(int x:adj[v]){
if(x==u)continue;
dfs(x,v);
}
tout[v] = timer;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i=0;i<n;i++)adj[i].clear();
vector<int>lab(n);
for(int i=0;i+1<n;i++){
adj[v[i]].push_back(u[i]);
adj[u[i]].push_back(v[i]);
}
timer = -1;
dfs(0,-1);
//for(int i=0;i<n;i++)cout<<tin[i]<<" "<<tout[i]<<'\n';
for(int i=0;i<n;i++)lab[i] = 1000*tin[i] + tout[i];
return lab;
}
int find_next_station(int s, int t, vector<int> c) {
int tl = t/1000;
int tr = t%1000;
int sl = s/1000;
int sr = s%1000;
bool out = 1;
if(sl <= tl && tr <= sr)out = 0;
//cout<<sl<<" "<<sr<<" "<<tl<<" "<<tr<<'\n';
for(int x:c){
int l = x/1000;
int r = x%1000;
if(l <= sl && sr <= r){
if(out)return x;
}
else if(l <= tl && tr <= r)return x;
}
}
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... |