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