#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID ((l+r)/2)
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;
#define EPS 1e-6
#define FOR(i,n) for(int i=0;i<((int)(n));i++)
#define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define FOA(v, a) for(auto v : a)
vector<vi> adj;
vi labels;
int cnt=0;
vi sub;
void dfs(int s, int p=-1){
labels[s] = cnt++;
for(auto v : adj[s]) if(v!=p) dfs(v, s), sub[s]+=sub[v];
}
vi label(int n, int k, std::vector<int> u, std::vector<int> v) {
cnt = 0;
adj.assign(n, vi());
sub.assign(n, 1);
labels.assign(n, 0);
FOR(i,n-1){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0);
//FOR(i,n) cout<<labels[i]<<" "<<sub[i]-1<<endl;
FOR(i,n) labels[i] = labels[i]*1000 + sub[i] - 1;
//FOA(v, labels) cout<<v<<" "; cout<<endl;
return labels;
}
int get_s(int x){ return x % 1000; }
int find_next_station(int s, int t, std::vector<int> c) {
//cout<<s<<" "<<t<<endl;
int lt = t/1000;
int ls = s/1000;
int prev = ls;
sort(c.begin(), c.end());
FOA(x, c){
if((x/1000)<ls) continue;
int xs = get_s(x);
if(prev<lt && lt<=prev+xs+1) return x;
prev+=xs+1;
}
//cout<<s<<" "<<get_s(s)<<endl;
return *min_element(c.begin(), c.end());
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
324 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6003 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
328 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1510 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
623 ms |
616 KB |
Output is correct |
2 |
Correct |
668 ms |
612 KB |
Output is correct |
3 |
Correct |
1053 ms |
472 KB |
Output is correct |
4 |
Correct |
890 ms |
408 KB |
Output is correct |
5 |
Correct |
678 ms |
500 KB |
Output is correct |
6 |
Correct |
500 ms |
616 KB |
Output is correct |
7 |
Correct |
535 ms |
596 KB |
Output is correct |
8 |
Correct |
3 ms |
480 KB |
Output is correct |
9 |
Correct |
6 ms |
452 KB |
Output is correct |
10 |
Correct |
2 ms |
472 KB |
Output is correct |
11 |
Correct |
883 ms |
400 KB |
Output is correct |
12 |
Correct |
440 ms |
608 KB |
Output is correct |
13 |
Correct |
489 ms |
716 KB |
Output is correct |
14 |
Correct |
461 ms |
540 KB |
Output is correct |
15 |
Correct |
71 ms |
472 KB |
Output is correct |
16 |
Correct |
86 ms |
552 KB |
Output is correct |
17 |
Correct |
119 ms |
528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
890 ms |
496 KB |
Output is correct |
2 |
Correct |
793 ms |
404 KB |
Output is correct |
3 |
Correct |
684 ms |
400 KB |
Output is correct |
4 |
Correct |
3 ms |
472 KB |
Output is correct |
5 |
Correct |
5 ms |
472 KB |
Output is correct |
6 |
Correct |
2 ms |
480 KB |
Output is correct |
7 |
Correct |
689 ms |
576 KB |
Output is correct |
8 |
Correct |
1073 ms |
404 KB |
Output is correct |
9 |
Correct |
755 ms |
500 KB |
Output is correct |
10 |
Correct |
627 ms |
400 KB |
Output is correct |
11 |
Correct |
6 ms |
484 KB |
Output is correct |
12 |
Correct |
7 ms |
480 KB |
Output is correct |
13 |
Correct |
6 ms |
480 KB |
Output is correct |
14 |
Correct |
5 ms |
472 KB |
Output is correct |
15 |
Correct |
2 ms |
472 KB |
Output is correct |
16 |
Correct |
574 ms |
496 KB |
Output is correct |
17 |
Correct |
587 ms |
492 KB |
Output is correct |
18 |
Correct |
604 ms |
400 KB |
Output is correct |
19 |
Correct |
630 ms |
524 KB |
Output is correct |
20 |
Correct |
614 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
660 ms |
728 KB |
Partially correct |
2 |
Partially correct |
490 ms |
616 KB |
Partially correct |
3 |
Correct |
969 ms |
400 KB |
Output is correct |
4 |
Partially correct |
703 ms |
492 KB |
Partially correct |
5 |
Partially correct |
655 ms |
400 KB |
Partially correct |
6 |
Partially correct |
612 ms |
560 KB |
Partially correct |
7 |
Partially correct |
490 ms |
528 KB |
Partially correct |
8 |
Partially correct |
3 ms |
472 KB |
Partially correct |
9 |
Partially correct |
5 ms |
472 KB |
Partially correct |
10 |
Partially correct |
2 ms |
472 KB |
Partially correct |
11 |
Partially correct |
554 ms |
616 KB |
Partially correct |
12 |
Partially correct |
620 ms |
528 KB |
Partially correct |
13 |
Correct |
998 ms |
400 KB |
Output is correct |
14 |
Partially correct |
773 ms |
408 KB |
Partially correct |
15 |
Partially correct |
612 ms |
472 KB |
Partially correct |
16 |
Partially correct |
510 ms |
528 KB |
Partially correct |
17 |
Partially correct |
733 ms |
404 KB |
Partially correct |
18 |
Partially correct |
587 ms |
780 KB |
Partially correct |
19 |
Partially correct |
554 ms |
608 KB |
Partially correct |
20 |
Partially correct |
487 ms |
616 KB |
Partially correct |
21 |
Partially correct |
68 ms |
464 KB |
Partially correct |
22 |
Partially correct |
100 ms |
528 KB |
Partially correct |
23 |
Partially correct |
115 ms |
564 KB |
Partially correct |
24 |
Partially correct |
5 ms |
472 KB |
Partially correct |
25 |
Partially correct |
9 ms |
472 KB |
Partially correct |
26 |
Partially correct |
6 ms |
480 KB |
Partially correct |
27 |
Partially correct |
5 ms |
480 KB |
Partially correct |
28 |
Partially correct |
2 ms |
476 KB |
Partially correct |
29 |
Partially correct |
544 ms |
400 KB |
Partially correct |
30 |
Partially correct |
518 ms |
400 KB |
Partially correct |
31 |
Partially correct |
597 ms |
556 KB |
Partially correct |
32 |
Partially correct |
600 ms |
404 KB |
Partially correct |
33 |
Partially correct |
616 ms |
528 KB |
Partially correct |
34 |
Partially correct |
368 ms |
616 KB |
Partially correct |
35 |
Partially correct |
566 ms |
520 KB |
Partially correct |
36 |
Partially correct |
587 ms |
648 KB |
Partially correct |
37 |
Partially correct |
566 ms |
700 KB |
Partially correct |
38 |
Partially correct |
458 ms |
640 KB |
Partially correct |
39 |
Partially correct |
533 ms |
644 KB |
Partially correct |
40 |
Partially correct |
541 ms |
696 KB |
Partially correct |
41 |
Partially correct |
576 ms |
576 KB |
Partially correct |
42 |
Partially correct |
66 ms |
528 KB |
Partially correct |
43 |
Partially correct |
111 ms |
528 KB |
Partially correct |
44 |
Partially correct |
125 ms |
528 KB |
Partially correct |
45 |
Partially correct |
170 ms |
528 KB |
Partially correct |
46 |
Partially correct |
345 ms |
532 KB |
Partially correct |
47 |
Partially correct |
396 ms |
528 KB |
Partially correct |
48 |
Partially correct |
74 ms |
652 KB |
Partially correct |
49 |
Partially correct |
63 ms |
528 KB |
Partially correct |