# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
719521 | mseebacher | Stations (IOI20_stations) | C++17 | 852 ms | 544 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;
#define MAXI (int)1e3+10
vector<int> ad[MAXI];
vector<int> labels;
vector<int> in(MAXI,0);
vector<int> out(MAXI,0);
int counter = 0;
// 1 .. 1e3
// 1e3+1 ... 2e3
void dfs(int x,int e){
in[x] = counter++;
for(auto s: ad[x]){
if(s == e) continue;
dfs(s,x);
}
out[x] = counter;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
labels.assign(n,0);
for(int i = 0;i<MAXI;i++) ad[i].clear();
counter = 0;
for(int i = 0;i<n-1;i++){
ad[u[i]].push_back(v[i]);
ad[v[i]].push_back(u[i]);
}
dfs(0,-1);
for(int i = 0;i<n;i++){
labels[i] = in[i]*1000+out[i];
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
int in_t = t/1000;
int out_t = t%1000;
for(int i = 0;i<(int)c.size();i++){
int in_i = c[i]/1000;
int out_i = c[i]%1000;
if(in_i <= in_t && out_i >= in_t) return c[i];
}
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... |