# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
586596 | PiejanVDC | Stations (IOI20_stations) | C++17 | 3056 ms | 2097152 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];
vector<int>labelss;
int id;
int dfs(int u, int e = -1) {
labelss[u] = 1000*id;
id++;
int sz = 0;
for(auto z : adj[u]) if(z != e) {
sz += dfs(z, u);
}
labelss[u] += sz;
return ++sz;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for(int i = 0 ; i < n-1 ; i++)
adj[u[i]].push_back(v[i]), adj[v[i]].push_back(u[i]);
labelss.resize(n);
dfs(0);
return labelss;
}
int find_next_station(int s, int t, std::vector<int> c) {
int ID = s / 1000;
int SZ = s % 1000;
int ID_T = t / 1000;
if(ID_T < ID || ID_T > ID + SZ)
return c[0];
int curr = ID;
for(int i = 1 ; i < c.size() ; i++) {
curr += 1 + c[i] % 1000;
if(curr >= ID_T)
return c[i];
}
assert(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... |