# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
308621 | lordlorinc | Stations (IOI20_stations) | C++17 | 1190 ms | 1268 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>
using namespace std;
vector<vector<int> > sor;
vector<bool> volt;
vector<int> eleres, tavozas;
int time = -1;
void bejaras (int hely){
time++;
eleres[hely] = time;
volt[hely] = true;
for (int x : sor[hely]){
if (volt[x] == false){
bejaras(x);
}
}
time++;
tavozas[hely] = time;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
sor.assign(n, vector<int>(0));
volt.assign(n, false);
eleres.assign(n, 0);
tavozas.assign(n, 0);
time = -1;
for (int i = 0; i < u.size(); i++){
sor[u[i]].push_back(v[i]);
sor[v[i]].push_back(u[i]);
}
bejaras(0);
vector<int> labels(n);
for (int i = 0; i < n; i++) labels[i] = eleres[i] * 2000 + tavozas[i];
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
pair<int, int> hely, cel;
hely.first = s / 2000;
hely.second = s % 2000;
cel.first = t / 2000;
cel.second = t % 2000;
vector<pair<int, int> > szomszedok(c.size());
for (int i = 0; i < c.size(); i++){
szomszedok[i].first = c[i] / 2000;
szomszedok[i].second = c[i] % 2000;
}
int szuloindex = -1;
for (int i = 0; i < c.size(); i++) {
if (szomszedok[i].first < hely.first) szuloindex = i;
}
for (int i = 0; i < c.size(); i++){
if (i != szuloindex){
if (szomszedok[i].first <= cel.first && szomszedok[i].second >= cel.second){
return c[i];
}
}
}
return c[szuloindex];
}
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... |