#include <bits/stdc++.h>
#define forint(i, N) for (int i = 0; i < (N); i++)
using namespace std;
vector<int> value;
vector<bool> visited;
int minval = 0;
void go(vector< vector<int> >& graph, int n, bool odd) {
visited[n] = true;
if (odd) {
for (auto& i : graph[n]) {
if (!visited[i]) {
go(graph, i, !odd);
}
}
value[n] = minval;
minval++;
}
else {
value[n] = minval;
minval++;
for (auto& i : graph[n]) {
if (!visited[i]) {
go(graph, i, !odd);
}
}
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector< vector<int> > graph(n);
visited.clear();
visited.resize(n);
fill(visited.begin(), visited.end(), false);
value.clear();
value.resize(n);
fill(value.begin(), value.end(), -1);
forint(i, n - 1) {
graph[u[i]].push_back(v[i]);
graph[v[i]].push_back(u[i]);
}
go(graph, 0, true);
return value;
}
int find_next_station(int s, int t, vector<int> c) {
if (c.size() == 1) {
return c[0];
}
if (s < c[0]) {
if (t < s || t > c[c.size() - 1]) {
return c[c.size() - 1];
}
}
else {
if (t > s || t < c[0]) {
return c[0];
}
}
int left = 0;
int right = c.size() - 1;
while (left + 1 < right) {
if (t == c[left] || t == c[right]) {
return t;
}
int mid = (left + right) / 2;
if (t <= c[mid]) {
right = mid;
}
else {
left = mid;
}
}
if (s < c[0]) {
return c[right];
}
return c[left];
/*
if (s < c[0]) {
if (t < s || t > c[c.size() - 1]) {
return c[c.size() - 1];
}
forint(i, c.size()) {
if (c[i] >= t) {
return c[i];
}
}
}
else {
if (t > s || t < c[0]) {
return c[0];
}
for (int i = c.size() - 1; i >= 0; i--) {
if (t >= c[i]) {
return c[i];
}
}
}
*/
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
448 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=0, label=1010 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
268 KB |
Invalid labels (values out of range). scenario=1, k=1000, vertex=0, label=1989 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
610 ms |
620 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1214 ms |
560 KB |
Output is correct |
2 |
Incorrect |
692 ms |
400 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
641 ms |
528 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |