#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
vector<vector<int>> v;
vector<int> lb, sz;
pair<int, int> div(int x){
return make_pair(x/1000, x%1000);
}
int in = 0;
void dfs(int nd, int ss){
lb[nd] = in++;
for(int x: v[nd]) if(x!=ss) dfs(x, nd);
for(int x: v[nd]) if(x!=ss) sz[nd]+=sz[x];
lb[nd]+=sz[nd]*1000;
}
vector<int> label(int n, int k, vector<int> aa, vector<int> bb){
v.assign(n, {});
lb.resize(n);
sz.resize(n, 1);
for(int i = 0; i < n-1; i++){
v[aa[i]].pb(bb[i]);
v[bb[i]].pb(aa[i]);
}
dfs(0, -1);
for(int x: lb) cerr << x << " ";
cerr << " d\n";
return lb;
}
int find_next_station(int s, int t, vector<int> c){
sort(c.begin(), c.end(), [&](int a, int b){return div(a).sc < div(b).sc;});
auto [a, b] = div(s);
cerr << s << " " << t << " d\n";
cerr << a << " " << b << " " << div(t).f << " " << div(t).sc << " d\n";
if(div(t).sc < b || div(t).sc > b+a) return c.front();
c.erase(c.begin());
for(int x: c){
auto [aa, bb] = div(x);
if(t > bb && t <= bb+aa) return x;
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
45 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
492 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=10000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
47 ms |
568 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=996000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
26 ms |
604 KB |
Invalid labels (values out of range). scenario=2, k=1000000, vertex=0, label=5915999 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3036 ms |
3116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
612 KB |
Invalid labels (values out of range). scenario=6, k=1000000000, vertex=0, label=1131140014 |
2 |
Halted |
0 ms |
0 KB |
- |