이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
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... |