#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
const int Nax = 1005;
class Undirected_Graph{
public:
int N, Timer = 0;
vector<vector<int>>adj;
vector<int>in, out;
Undirected_Graph(int _N):N(_N){
adj.resize(N);
out.resize(N);
in.resize(N);
}
inline void Add_Edge(int A, int B){
adj[A].push_back(B);
adj[B].push_back(A);
}
inline void Depth_First_Search(int Node, int Parent, int even = 1){
if (even)in[Node]=Timer++;
for (int& Next : adj[Node]){
if (Next == Parent)continue;
Depth_First_Search(Next,Node,even^1);
}
if (!even)in[Node]=Timer++;
}
};
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
Undirected_Graph G(n);
for (int i = 0; i < n - 1; i++){
G.Add_Edge(u[i],v[i]);
}
G.Depth_First_Search(0,0);
labels = G.in;
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (c.back() < s){
reverse(c.begin(),c.end());
}
for (int i = 0; i < (int)c.size(); i++){
if (t >= min(c[i],s) && t <= max(c[i],s))return c[i];
}
return c.back();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
465 ms |
504 KB |
Output is correct |
2 |
Correct |
385 ms |
548 KB |
Output is correct |
3 |
Correct |
670 ms |
504 KB |
Output is correct |
4 |
Correct |
498 ms |
420 KB |
Output is correct |
5 |
Correct |
467 ms |
416 KB |
Output is correct |
6 |
Correct |
390 ms |
508 KB |
Output is correct |
7 |
Correct |
420 ms |
548 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
4 ms |
500 KB |
Output is correct |
10 |
Correct |
0 ms |
500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
312 ms |
544 KB |
Output is correct |
2 |
Correct |
363 ms |
544 KB |
Output is correct |
3 |
Correct |
558 ms |
628 KB |
Output is correct |
4 |
Correct |
453 ms |
416 KB |
Output is correct |
5 |
Correct |
492 ms |
416 KB |
Output is correct |
6 |
Correct |
360 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
448 ms |
504 KB |
Output is correct |
2 |
Correct |
368 ms |
620 KB |
Output is correct |
3 |
Correct |
683 ms |
512 KB |
Output is correct |
4 |
Correct |
507 ms |
508 KB |
Output is correct |
5 |
Correct |
561 ms |
420 KB |
Output is correct |
6 |
Correct |
357 ms |
544 KB |
Output is correct |
7 |
Correct |
318 ms |
568 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
0 ms |
492 KB |
Output is correct |
11 |
Correct |
444 ms |
504 KB |
Output is correct |
12 |
Correct |
334 ms |
588 KB |
Output is correct |
13 |
Correct |
402 ms |
756 KB |
Output is correct |
14 |
Correct |
379 ms |
544 KB |
Output is correct |
15 |
Correct |
36 ms |
492 KB |
Output is correct |
16 |
Correct |
44 ms |
668 KB |
Output is correct |
17 |
Correct |
100 ms |
572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
742 ms |
416 KB |
Output is correct |
2 |
Correct |
480 ms |
416 KB |
Output is correct |
3 |
Correct |
522 ms |
420 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
5 ms |
496 KB |
Output is correct |
6 |
Correct |
0 ms |
492 KB |
Output is correct |
7 |
Correct |
479 ms |
428 KB |
Output is correct |
8 |
Correct |
601 ms |
416 KB |
Output is correct |
9 |
Correct |
570 ms |
500 KB |
Output is correct |
10 |
Correct |
515 ms |
508 KB |
Output is correct |
11 |
Correct |
3 ms |
504 KB |
Output is correct |
12 |
Correct |
3 ms |
500 KB |
Output is correct |
13 |
Correct |
3 ms |
500 KB |
Output is correct |
14 |
Correct |
4 ms |
492 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
16 |
Correct |
473 ms |
420 KB |
Output is correct |
17 |
Correct |
333 ms |
420 KB |
Output is correct |
18 |
Correct |
412 ms |
420 KB |
Output is correct |
19 |
Correct |
327 ms |
416 KB |
Output is correct |
20 |
Correct |
418 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
450 ms |
496 KB |
Output is correct |
2 |
Correct |
464 ms |
508 KB |
Output is correct |
3 |
Correct |
674 ms |
504 KB |
Output is correct |
4 |
Correct |
583 ms |
496 KB |
Output is correct |
5 |
Correct |
609 ms |
420 KB |
Output is correct |
6 |
Correct |
374 ms |
500 KB |
Output is correct |
7 |
Correct |
338 ms |
548 KB |
Output is correct |
8 |
Correct |
1 ms |
500 KB |
Output is correct |
9 |
Correct |
3 ms |
500 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
381 ms |
500 KB |
Output is correct |
12 |
Correct |
395 ms |
500 KB |
Output is correct |
13 |
Correct |
695 ms |
416 KB |
Output is correct |
14 |
Correct |
587 ms |
416 KB |
Output is correct |
15 |
Correct |
489 ms |
504 KB |
Output is correct |
16 |
Correct |
313 ms |
548 KB |
Output is correct |
17 |
Correct |
480 ms |
416 KB |
Output is correct |
18 |
Correct |
404 ms |
588 KB |
Output is correct |
19 |
Correct |
373 ms |
576 KB |
Output is correct |
20 |
Correct |
363 ms |
548 KB |
Output is correct |
21 |
Correct |
50 ms |
492 KB |
Output is correct |
22 |
Correct |
64 ms |
668 KB |
Output is correct |
23 |
Correct |
82 ms |
600 KB |
Output is correct |
24 |
Correct |
4 ms |
496 KB |
Output is correct |
25 |
Correct |
4 ms |
492 KB |
Output is correct |
26 |
Correct |
3 ms |
492 KB |
Output is correct |
27 |
Correct |
3 ms |
492 KB |
Output is correct |
28 |
Correct |
1 ms |
492 KB |
Output is correct |
29 |
Correct |
436 ms |
504 KB |
Output is correct |
30 |
Correct |
465 ms |
556 KB |
Output is correct |
31 |
Correct |
433 ms |
504 KB |
Output is correct |
32 |
Correct |
471 ms |
420 KB |
Output is correct |
33 |
Correct |
444 ms |
416 KB |
Output is correct |
34 |
Correct |
261 ms |
548 KB |
Output is correct |
35 |
Correct |
295 ms |
632 KB |
Output is correct |
36 |
Correct |
390 ms |
580 KB |
Output is correct |
37 |
Correct |
353 ms |
556 KB |
Output is correct |
38 |
Correct |
377 ms |
628 KB |
Output is correct |
39 |
Correct |
368 ms |
592 KB |
Output is correct |
40 |
Correct |
384 ms |
632 KB |
Output is correct |
41 |
Correct |
291 ms |
756 KB |
Output is correct |
42 |
Correct |
55 ms |
620 KB |
Output is correct |
43 |
Correct |
104 ms |
616 KB |
Output is correct |
44 |
Correct |
86 ms |
544 KB |
Output is correct |
45 |
Correct |
122 ms |
568 KB |
Output is correct |
46 |
Correct |
198 ms |
548 KB |
Output is correct |
47 |
Correct |
239 ms |
500 KB |
Output is correct |
48 |
Correct |
48 ms |
732 KB |
Output is correct |
49 |
Correct |
37 ms |
668 KB |
Output is correct |