#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int dydis = 1000;
vector<int> gr[dydis];
int enter[dydis];
int leave[dydis];
vector<int> ret (dydis);
int dbInd = 0;
void dfs(int v, int came, int h = 0){
enter[v] = dbInd++;
for(auto x : gr[v]){
if(x == came) continue;
dfs(x, v, h+1);
}
leave[v] = dbInd++;
//cout << v << ": " << enter[v] << ", " << leave[v] << ", o dedu ";
if(h & 1){
ret[v] = leave[v];
//cout << leave[v] << endl;
}else{
ret[v] = enter[v];
//cout << enter[v] << endl;
}
//cout << "enter " << v << " - " << enter[v] << ", o leave " << leave[v]-1 << endl;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i = 0; i < n; i++){
gr[i].clear();
}
dbInd = 0;
ret.resize(n);
for(int i = 0; i < n-1; i++){
gr[u[i]].push_back(v[i]);
gr[v[i]].push_back(u[i]);
}
dfs(0, -1);
return ret;
}
int find_next_station(int s, int t, vector<int> c) {
bool yraMaz = 1;
for(auto x : c){
if(x < s) yraMaz = 0;
}
//cout << "gaunu " << s << ": "; for(auto x : c) cout << x<< " "; cout << "| ";
if(yraMaz){ // as enter
int dd = c.back();
int last = s;
//cout << "jis yra enter" << endl;
for(auto x : c){
if(x == dd && s != 0) continue;
int enter = last+1;
int leave = x;
if(enter <= t && t <= leave) return x;
last = leave;
}
return c.back();
}else{ // as leave
//cout << "jis yra leave" << endl;
for(int i = 1; i < (int)c.size(); i++){
int enter = c[i];
int leave = (i == (int)c.size() - 1 ? s - 1 : c[i+1] - 1);
if(enter <= t && t <= leave){
return c[i];
}
}
return c[0];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
436 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
312 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
555 ms |
652 KB |
Output is correct |
2 |
Correct |
454 ms |
640 KB |
Output is correct |
3 |
Correct |
1212 ms |
500 KB |
Output is correct |
4 |
Correct |
761 ms |
400 KB |
Output is correct |
5 |
Correct |
824 ms |
528 KB |
Output is correct |
6 |
Correct |
500 ms |
648 KB |
Output is correct |
7 |
Correct |
512 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
596 KB |
Output is correct |
9 |
Correct |
7 ms |
652 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
686 ms |
520 KB |
Output is correct |
12 |
Correct |
561 ms |
744 KB |
Output is correct |
13 |
Correct |
550 ms |
744 KB |
Output is correct |
14 |
Correct |
471 ms |
656 KB |
Output is correct |
15 |
Correct |
56 ms |
556 KB |
Output is correct |
16 |
Correct |
81 ms |
528 KB |
Output is correct |
17 |
Correct |
127 ms |
652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
981 ms |
552 KB |
Output is correct |
2 |
Correct |
841 ms |
680 KB |
Output is correct |
3 |
Correct |
625 ms |
516 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
4 ms |
724 KB |
Output is correct |
6 |
Correct |
2 ms |
596 KB |
Output is correct |
7 |
Correct |
689 ms |
524 KB |
Output is correct |
8 |
Correct |
1275 ms |
528 KB |
Output is correct |
9 |
Correct |
822 ms |
548 KB |
Output is correct |
10 |
Correct |
729 ms |
524 KB |
Output is correct |
11 |
Correct |
7 ms |
596 KB |
Output is correct |
12 |
Correct |
7 ms |
596 KB |
Output is correct |
13 |
Correct |
5 ms |
596 KB |
Output is correct |
14 |
Correct |
5 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
696 ms |
496 KB |
Output is correct |
17 |
Correct |
657 ms |
528 KB |
Output is correct |
18 |
Correct |
663 ms |
520 KB |
Output is correct |
19 |
Correct |
823 ms |
524 KB |
Output is correct |
20 |
Correct |
522 ms |
528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
593 ms |
640 KB |
Partially correct |
2 |
Partially correct |
629 ms |
528 KB |
Partially correct |
3 |
Correct |
1212 ms |
528 KB |
Output is correct |
4 |
Correct |
713 ms |
400 KB |
Output is correct |
5 |
Correct |
646 ms |
520 KB |
Output is correct |
6 |
Partially correct |
514 ms |
804 KB |
Partially correct |
7 |
Partially correct |
644 ms |
528 KB |
Partially correct |
8 |
Correct |
3 ms |
548 KB |
Output is correct |
9 |
Correct |
5 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Partially correct |
550 ms |
576 KB |
Partially correct |
12 |
Partially correct |
609 ms |
564 KB |
Partially correct |
13 |
Correct |
1174 ms |
400 KB |
Output is correct |
14 |
Correct |
890 ms |
724 KB |
Output is correct |
15 |
Correct |
753 ms |
560 KB |
Output is correct |
16 |
Partially correct |
625 ms |
648 KB |
Partially correct |
17 |
Correct |
658 ms |
528 KB |
Output is correct |
18 |
Partially correct |
544 ms |
732 KB |
Partially correct |
19 |
Partially correct |
602 ms |
760 KB |
Partially correct |
20 |
Partially correct |
491 ms |
520 KB |
Partially correct |
21 |
Correct |
82 ms |
592 KB |
Output is correct |
22 |
Partially correct |
69 ms |
568 KB |
Partially correct |
23 |
Partially correct |
154 ms |
720 KB |
Partially correct |
24 |
Correct |
7 ms |
468 KB |
Output is correct |
25 |
Correct |
5 ms |
724 KB |
Output is correct |
26 |
Correct |
5 ms |
596 KB |
Output is correct |
27 |
Correct |
5 ms |
596 KB |
Output is correct |
28 |
Correct |
3 ms |
596 KB |
Output is correct |
29 |
Correct |
735 ms |
524 KB |
Output is correct |
30 |
Correct |
694 ms |
400 KB |
Output is correct |
31 |
Correct |
570 ms |
644 KB |
Output is correct |
32 |
Correct |
519 ms |
524 KB |
Output is correct |
33 |
Correct |
795 ms |
552 KB |
Output is correct |
34 |
Partially correct |
380 ms |
624 KB |
Partially correct |
35 |
Partially correct |
597 ms |
744 KB |
Partially correct |
36 |
Partially correct |
474 ms |
668 KB |
Partially correct |
37 |
Partially correct |
574 ms |
744 KB |
Partially correct |
38 |
Partially correct |
487 ms |
848 KB |
Partially correct |
39 |
Partially correct |
524 ms |
728 KB |
Partially correct |
40 |
Partially correct |
516 ms |
972 KB |
Partially correct |
41 |
Partially correct |
644 ms |
632 KB |
Partially correct |
42 |
Partially correct |
86 ms |
656 KB |
Partially correct |
43 |
Partially correct |
122 ms |
552 KB |
Partially correct |
44 |
Partially correct |
189 ms |
600 KB |
Partially correct |
45 |
Partially correct |
224 ms |
580 KB |
Partially correct |
46 |
Partially correct |
349 ms |
552 KB |
Partially correct |
47 |
Partially correct |
402 ms |
628 KB |
Partially correct |
48 |
Partially correct |
56 ms |
656 KB |
Partially correct |
49 |
Partially correct |
67 ms |
784 KB |
Partially correct |