# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1205230 | notme | Stations (IOI20_stations) | C++20 | 304 ms | 580 KiB |
#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int maxn = 2e3 + 10;
vector < int > g[maxn];
int tmr = 0;
int tin[maxn], tout[maxn];
void dfs(int beg, int from)
{
tmr ++;
tin[beg] = tmr;
for (auto nb: g[beg])
{
if(nb == from)continue;
dfs(nb, beg);
}
tmr ++;
tout[beg] = tmr;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v)
{
for (int i = 0; i < n; ++ i)
g[i].clear();
for (int i = 0; i < n; ++ i)
tin[i] = tout[i] = 0;
tmr = 0;
for (int i = 0; i < n-1; ++ i)
{
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
dfs(0, -1);
std::vector<int> labels(n);
for (int i = 0; i < n; i++)
{
labels[i] = tout[i];
assert(labels[i] > 0);
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c)
{
int lst = c.back();
if(lst > s)
{
int par = c.back();
c.pop_back();
if(t == par)return par;
if(t > s)return par;
if(t < s && t < par)
{
int bigger = 0;
for (auto x: c)
{
if(x >= t)
{
return x;
}
}
return par;
}
return par;
}
else
{
for (auto x: c)
{
if(x >= t)
return x;
}
}
}
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... |