# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
308162 | ainta | Stations (IOI20_stations) | C++17 | 1013 ms | 1160 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 <vector>
#include <algorithm>
using namespace std;
vector<int>E[1010];
int Num[1010], cnt;
void DFS(int a, int pp, int dep){
int i;
if(!dep)Num[a]=++cnt;
for(auto &x : E[a]){
if(x==pp)continue;
DFS(x,a,!dep);
}
if(dep)Num[a]=++cnt;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
cnt = 0;
for(int i=0;i<n;i++)E[i].clear();
for (int i = 0; i < n; i++) {
labels[i] = i;
}
for(int i=0;i<n-1;i++){
E[u[i]].push_back(v[i]);
E[v[i]].push_back(u[i]);
}
DFS(0,-1,0);
for(int i=0;i<n;i++){
labels[i] = Num[i]-1;
}
return labels;
}
bool Include(int a, int b){
}
int find_next_station(int s, int t, std::vector<int> c) {
int i;
int b = s, e = s;
int sz =c.size();
if(s < c[0]){
if(sz>=2)e = c[sz-2];
if(b<=t && t<=e){
for(auto &x : c){
if(x>=t)return x;
}
}
return c[sz-1];
}
else{
if(sz>=2)b = c[1];
if(b<=t && t<=e){
reverse(c.begin(),c.end());
for(auto &x : c){
if(x<=t)return x;
}
}
return c[0];
}
}
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... |