#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
vector < int > lb, adj[N];
int num, timer = 1;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for ( int i = 0; i < n; i++ ) {
adj[i].clear();
}
for ( int i = 0; i < n - 1; i++ ) {
int x = u[i], y = v[i];
adj[x].push_back(y);
adj[y].push_back(x);
}
num = 0;
lb.clear();
lb.resize(n);
queue < int > q;
q.push( 0 );
vector < int > used(n + 1);
used[0] = 1;
while ( !q.empty() ) {
int v = q.front();
q.pop();
lb[v] = num++;
for ( auto u: adj[v] ) {
if ( !used[u] ) {
q.push( u );
used[u] = 1;
}
}
}
return lb;
}
bool is_ancestor( int b, int a ) {
if ( b == 0 ) {
return 1;
}
int pr = (a - 1) / 2;
while ( pr > 0 ) {
if ( pr == b ) {
return 1;
}
pr = (pr - 1) / 2;
}
return 0;
}
int find_next_station(int s, int t, std::vector<int> c) {
if ( is_ancestor( t, s ) ) {
return (s - 1) / 2;
}
if ( is_ancestor( s * 2, t ) ) {
return s * 2;
}
return s * 2 + 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
526 ms |
880 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
426 ms |
736 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
525 ms |
864 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1000 ms |
736 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
606 ms |
1068 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |