#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 7;
void dfs( vector<vector<int>> adj, int v, int p, vector<int> &lb, int &cnt ) {
lb[v] = cnt++;
for ( auto u: adj[v] ) {
if ( u != p ) {
dfs( adj, u, v, lb, cnt );
}
}
if ( p != -1 ) {
lb[v] *= 1000;
lb[v] += cnt - 1;
}
else {
lb[v] *= 1000;
}
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector<vector<int>> adj(n + 7);
for ( int i = 0; i < n - 1; i++ ) {
adj[ u[i] ].push_back( v[i] );
adj[ v[i] ].push_back( u[i] );
}
int mx = -1, rt = 0;
for ( int i = 0; i < n; i++ ) {
if ( (int)adj[i].size() > mx ) {
mx = adj[i].size();
rt = i;
}
}
int cnt = 0;
vector<int> lb(n + 7, 0);
dfs( adj, rt, -1 , lb, cnt );
vector < int > lbs;
for ( int i = 0; i < n; i++ ) {
lbs.push_back( lb[i] );
}
return lbs;
}
int find_next_station(int s, int t, std::vector<int> c) {
int i = s / 1000;
int j = t / 1000;
if ( s == 0 ) {
for ( auto v: c ) {
int x = v / 1000, y = v % 1000;
if ( j >= x && j <= y ) {
return v;
}
}
}
int pr = -1;
for ( auto v: c ) {
int x = v / 1000, y = v % 1000;
if ( x < i ) {
pr = v;
}
if ( j >= x && j <= y ) {
return v;
}
}
assert( pr != -1 );
return pr;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
306 ms |
55296 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
541 ms |
928 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1485 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
975 ms |
55628 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1001 ms |
480 KB |
Output is correct |
2 |
Correct |
921 ms |
480 KB |
Output is correct |
3 |
Correct |
707 ms |
528 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Incorrect |
5 ms |
468 KB |
Wrong query response. |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
991 ms |
55692 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |