# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
730093 | danikoynov | Stations (IOI20_stations) | C++14 | 1012 ms | 892 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 = 1010;
vector < int > g[maxn], order, my_labels;
int in[maxn], out[maxn], timer, par[maxn], depth[maxn];
void dfs(int v, int p)
{
if (depth[v] % 2 == 0)
in[v] = timer ++;
par[v] = p;
order.push_back(v);
for (int u : g[v])
{
if (u == p)
continue;
depth[u] = depth[v] + 1;
dfs(u, v);
}
if (depth[v] % 2 == 1)
out[v] = timer ++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
for (int i = 0; i < n; i ++)
{
g[i].clear();
}
timer = 0;
order.clear();
my_labels.clear();
for (int i = 0; i < v.size(); i ++)
{
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
my_labels.resize(n);
dfs(0, 0);
for (int i = 0; i < n; i ++)
{
if (depth[i] % 2 == 0)
my_labels[i] = in[i];
else
my_labels[i] = out[i];
}
return my_labels;
}
int used[maxn];
int find_next_station(int s, int t, vector<int> c)
{
///return 0;
sort(c.begin(), c.end());
if (c.size() == 1)
return c[0];
int m = c.size();
if (s < c[0])
{
int tin = s;
int tout = c[m - 2] + 1;
if (t < tin || t > tout)
return c[m - 1];
int pt = 0;
while(c[pt] < t)
pt ++;
return c[pt];
}
else
{
int tin = c[1] - 1;
int tout = s;
if (t < tin || t > tout)
return c[0];
int pt = c.size() - 1;
while(c[pt] > t)
pt --;
return c[pt];
}
}
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... |