#include <bits/stdc++.h>
#include "stations.h"
using namespace std;
using ll = long long;
using ld = long double;
#define fi first
#define se second
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
vi col;
int timer = 0;
vector<vi> g;
void dfs(int v, int p, int f){
if(f == 0){
col[v] = timer++;
}
for(auto u : g[v]){
if(u == p){
continue;
}
dfs(u, v, 1 - f);
}
if(f){
col[v] = timer++;
}
}
vi label(int n, int k, vi u, vi v){
k++;
col.assign(n, 0);
g.resize(n);
for(int i = 0; i < n; i++){
g[i].clear();
}
for(int i = 0; i < n - 1; i++){
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
dfs(0, 0, 0);
return col;
}
int find_next_station(int s, int t, vi c){
sort(all(c));
if(sz(c) == 1){
return c[0];
}
if(s == 0){
for(auto ele : c){
if(t <= ele){
return ele;
}
}
return c.back();
}
int cnt[2] = {0, 0};
for(auto ele : c){
if(ele < s){
cnt[1]++;
}else{
cnt[0]++;
}
}
if(cnt[0] > cnt[1]){
//fs = 0
for(int i = 0; i + 1 < sz(c); i++){
if(t >= s && t <= c[i]){
return c[i];
}
}
return c.back();
}else{
//fs = 1
for(int i = sz(c) - 1; i > 0; i--){
if(t >= c[i] && t <= s){
return c[i];
}
}
return c[0];
}
}
/*int main(){
vi c = label(5, 10, {0, 1, 1, 2}, {1, 2, 3, 4});
for(int i = 0; i < 5; i++){
cout << c[i] << ' ';
}
cout << '\n';
cout << find_next_station(c[2], c[0], {c[1], c[4]}) << '\n';
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1008 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (values out of range). scenario=1, k=1000, vertex=1, label=1507 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
363 ms |
940 KB |
Output is correct |
2 |
Correct |
283 ms |
940 KB |
Output is correct |
3 |
Correct |
638 ms |
936 KB |
Output is correct |
4 |
Correct |
430 ms |
684 KB |
Output is correct |
5 |
Correct |
382 ms |
684 KB |
Output is correct |
6 |
Correct |
296 ms |
684 KB |
Output is correct |
7 |
Correct |
323 ms |
684 KB |
Output is correct |
8 |
Correct |
2 ms |
764 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
427 ms |
780 KB |
Output is correct |
12 |
Correct |
326 ms |
768 KB |
Output is correct |
13 |
Correct |
336 ms |
1188 KB |
Output is correct |
14 |
Correct |
310 ms |
684 KB |
Output is correct |
15 |
Correct |
27 ms |
776 KB |
Output is correct |
16 |
Correct |
36 ms |
704 KB |
Output is correct |
17 |
Correct |
55 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
631 ms |
684 KB |
Output is correct |
2 |
Correct |
413 ms |
684 KB |
Output is correct |
3 |
Correct |
426 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
776 KB |
Output is correct |
5 |
Correct |
2 ms |
768 KB |
Output is correct |
6 |
Correct |
0 ms |
768 KB |
Output is correct |
7 |
Correct |
354 ms |
684 KB |
Output is correct |
8 |
Correct |
605 ms |
684 KB |
Output is correct |
9 |
Correct |
445 ms |
684 KB |
Output is correct |
10 |
Correct |
393 ms |
684 KB |
Output is correct |
11 |
Correct |
2 ms |
776 KB |
Output is correct |
12 |
Correct |
2 ms |
768 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
2 ms |
776 KB |
Output is correct |
15 |
Correct |
1 ms |
776 KB |
Output is correct |
16 |
Correct |
332 ms |
684 KB |
Output is correct |
17 |
Correct |
369 ms |
684 KB |
Output is correct |
18 |
Correct |
324 ms |
684 KB |
Output is correct |
19 |
Correct |
328 ms |
684 KB |
Output is correct |
20 |
Correct |
323 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
371 ms |
1192 KB |
Partially correct |
2 |
Partially correct |
309 ms |
940 KB |
Partially correct |
3 |
Correct |
615 ms |
684 KB |
Output is correct |
4 |
Correct |
437 ms |
684 KB |
Output is correct |
5 |
Correct |
419 ms |
684 KB |
Output is correct |
6 |
Partially correct |
297 ms |
684 KB |
Partially correct |
7 |
Correct |
297 ms |
684 KB |
Output is correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
3 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
776 KB |
Output is correct |
11 |
Partially correct |
301 ms |
684 KB |
Partially correct |
12 |
Partially correct |
339 ms |
684 KB |
Partially correct |
13 |
Correct |
607 ms |
688 KB |
Output is correct |
14 |
Correct |
489 ms |
684 KB |
Output is correct |
15 |
Correct |
390 ms |
684 KB |
Output is correct |
16 |
Correct |
290 ms |
684 KB |
Output is correct |
17 |
Correct |
382 ms |
684 KB |
Output is correct |
18 |
Partially correct |
303 ms |
684 KB |
Partially correct |
19 |
Partially correct |
285 ms |
764 KB |
Partially correct |
20 |
Correct |
310 ms |
684 KB |
Output is correct |
21 |
Correct |
28 ms |
768 KB |
Output is correct |
22 |
Partially correct |
45 ms |
684 KB |
Partially correct |
23 |
Partially correct |
69 ms |
700 KB |
Partially correct |
24 |
Correct |
3 ms |
768 KB |
Output is correct |
25 |
Correct |
4 ms |
776 KB |
Output is correct |
26 |
Correct |
2 ms |
764 KB |
Output is correct |
27 |
Correct |
1 ms |
768 KB |
Output is correct |
28 |
Correct |
0 ms |
768 KB |
Output is correct |
29 |
Correct |
333 ms |
684 KB |
Output is correct |
30 |
Correct |
320 ms |
684 KB |
Output is correct |
31 |
Correct |
315 ms |
684 KB |
Output is correct |
32 |
Correct |
340 ms |
684 KB |
Output is correct |
33 |
Correct |
326 ms |
684 KB |
Output is correct |
34 |
Partially correct |
197 ms |
684 KB |
Partially correct |
35 |
Partially correct |
276 ms |
684 KB |
Partially correct |
36 |
Partially correct |
291 ms |
940 KB |
Partially correct |
37 |
Partially correct |
294 ms |
772 KB |
Partially correct |
38 |
Partially correct |
305 ms |
1020 KB |
Partially correct |
39 |
Partially correct |
261 ms |
776 KB |
Partially correct |
40 |
Partially correct |
284 ms |
932 KB |
Partially correct |
41 |
Partially correct |
297 ms |
1028 KB |
Partially correct |
42 |
Partially correct |
31 ms |
744 KB |
Partially correct |
43 |
Partially correct |
71 ms |
768 KB |
Partially correct |
44 |
Partially correct |
78 ms |
920 KB |
Partially correct |
45 |
Partially correct |
107 ms |
704 KB |
Partially correct |
46 |
Partially correct |
175 ms |
684 KB |
Partially correct |
47 |
Partially correct |
192 ms |
684 KB |
Partially correct |
48 |
Partially correct |
33 ms |
768 KB |
Partially correct |
49 |
Partially correct |
27 ms |
844 KB |
Partially correct |