#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];
}
if (t <= c[0]) {
return c[0];
}
}
else {
if (t > s || t < c[0]) {
return c[0];
}
if (t >= c[c.size() - 1]) {
return c[c.size() - 1];
}
}
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 |
328 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 |
284 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 |
Correct |
583 ms |
488 KB |
Output is correct |
2 |
Correct |
456 ms |
520 KB |
Output is correct |
3 |
Correct |
880 ms |
472 KB |
Output is correct |
4 |
Correct |
727 ms |
484 KB |
Output is correct |
5 |
Correct |
725 ms |
400 KB |
Output is correct |
6 |
Correct |
501 ms |
528 KB |
Output is correct |
7 |
Correct |
564 ms |
484 KB |
Output is correct |
8 |
Correct |
3 ms |
476 KB |
Output is correct |
9 |
Correct |
7 ms |
480 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Incorrect |
615 ms |
400 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
958 ms |
400 KB |
Output is correct |
2 |
Correct |
778 ms |
400 KB |
Output is correct |
3 |
Correct |
670 ms |
488 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
5 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
607 ms |
484 KB |
Output is correct |
8 |
Correct |
952 ms |
400 KB |
Output is correct |
9 |
Correct |
717 ms |
400 KB |
Output is correct |
10 |
Correct |
737 ms |
484 KB |
Output is correct |
11 |
Incorrect |
7 ms |
468 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
672 ms |
612 KB |
Partially correct |
2 |
Partially correct |
602 ms |
484 KB |
Partially correct |
3 |
Correct |
874 ms |
400 KB |
Output is correct |
4 |
Correct |
822 ms |
400 KB |
Output is correct |
5 |
Correct |
708 ms |
488 KB |
Output is correct |
6 |
Partially correct |
601 ms |
528 KB |
Partially correct |
7 |
Correct |
513 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
464 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
472 KB |
Output is correct |
11 |
Incorrect |
594 ms |
484 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |