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)
{
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);
}
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] + 2000;
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;
vector < int > children;
if (s > 2000)
{
/// in time case
sort(c.begin(), c.end());
if (t < s - 2000)
return c.back();
int pt = 0;
while(pt < c.back() && t <= c[pt])
pt ++;
pt --;
return c[pt];
}
else
{
sort(c.begin(), c.end());
if (t > s)
return c[0];
int pt = c.back() - 1;
while(pt >= 0 && t >= c[pt])
pt --;
pt ++;
return c[pt];
}
}
Compilation message (stderr)
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int i = 0; i < v.size(); i ++)
| ~~^~~~~~~~~~
# | 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... |