# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
828792 | Minindu206 | Stations (IOI20_stations) | C++14 | 3064 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[1005], vals;
int t = 0;
void dfs(int node, int p)
{
for (auto a : adj[node])
{
if (a != p)
dfs(a, node);
}
vals[node] = t++;
}
vector<int> label(int n, int k, vector<int> u, 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]);
}
vals.resize(n);
dfs(0, -1);
// for (int i = 0; i < n; i++)
// cout << vals[i] << "\n";
// cout << '\n';
return vals;
}
int find_next_station(int s, int t, vector<int> c)
{
if (c.size() == 1)
return c[0];
if (s < c[0])
{
if (s < t && t <= c[0])
return c[0];
for (int i = 1; i < c.size() - 1; i++)
{
if (c[i - 1] < t && t <= c[i])
return c[i];
}
return c.back();
}
if (c.back() <= t && t < s)
return c.back();
for (int i = c.size() - 2; i; i--)
{
if (c[i] <= t && t < c[i + 1])
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... |