# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
806855 | borisAngelov | Stations (IOI20_stations) | C++17 | 0 ms | 0 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;
const int maxn = 1005;
vector<int> g[maxn];
int tim = 0;
vector<int> hashed(n, 0);
void dfs(int node, int par)
{
hashed[node] = tim * 1000;
++tim;
for (int i = 0; i < g[node].size(); ++i)
{
if (g[node][i] != par)
{
dfs(g[node][i], node);
}
}
hashed[node] += (tim - 1);
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
for (int i = 0; i < u.size(); ++i)
{
int x = u[i];
int y = v[i];
g[x].push_back(y);
g[y].push_back(x);
}
dfs(0, -1);
return hashed;
}
int find_next_station(int s, int t, vector<int> c)
{
int in_s = s / 1000;
int out_s = s % 1000;
int in_t = t / 1000;
int out_t = t % 1000;
if (in_s <= in_t && out_t <= out_s)
{
int from = (in_s == 0 ? 0 : 1);
for (int i = from; i < c.size(); ++i)
{
int in_i = c[i] / 1000;
int out_i = c[i] % 1000;
if (in_i <= in_t && out_t <= out_i)
{
return c[i];
}
}
}
return c[0];
}