#include "stations.h"
#include <vector>
#include <iostream>
#define pb push_back
#define MAXN 1010
using namespace std;
vector<int> g[MAXN];
int in, out, tin[MAXN], tout[MAXN];
bool bio[MAXN];
void dfs(int u)
{
bio[u]=true;
tin[u]=in++;
for (auto v:g[u])
{
if (!bio[v]) dfs(v);
}
tout[u]=out++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for (int i=0; i<n; i++) { g[i].clear(); bio[i]=false; }
in=out=0;
for (int i=0; i<n-1; i++) { g[u[i]].pb(v[i]); g[v[i]].pb(u[i]); }
dfs(0);
vector<int> ret;
for (int i=0; i<n; i++)
{
//cout<<i<<" "<<tin[i]<<" "<<tout[i]<<endl;
ret.pb(tin[i]*1000+tout[i]);
//cout<<ret[ret.size()-1]<<endl;
}
return ret;
}
int find_next_station(int s, int t, std::vector<int> c) {
//for (int i=0; i<c.size(); i++) cout<<c[i]<<" s ";
//cout<<endl;
int in1, in2, out1, out2;
in1=s/1000; in2=t/1000;
out1=s%1000; out2=t%1000;
//cout<<"s: "<<in1<<" "<<out1<<endl;
//cout<<"t: "<<in2<<" "<<out2<<endl;
if (in1<=in2 && out1>=out2)
{
//cout<<"DA"<<endl;
for (int u:c)
{
int in3, out3;
in3=u/1000; out3=u%1000;
//cout<<u<<" jedan"<<endl;
if (in3<=in2 && out3>=out2 && in1<=in3 && out1>=out3) { return u; }
}
}
else
{
for (int u:c)
{
int in3, out3;
in3=u/1000; out3=u%1000;
if (in3<=in1 && out3>=out1) return u;
}
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:74:1: warning: control reaches end of non-void function [-Wreturn-type]
74 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
336 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6004 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
380 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 |
531 ms |
532 KB |
Output is correct |
2 |
Correct |
427 ms |
548 KB |
Output is correct |
3 |
Correct |
792 ms |
600 KB |
Output is correct |
4 |
Correct |
739 ms |
544 KB |
Output is correct |
5 |
Correct |
572 ms |
516 KB |
Output is correct |
6 |
Correct |
448 ms |
528 KB |
Output is correct |
7 |
Correct |
440 ms |
536 KB |
Output is correct |
8 |
Correct |
1 ms |
620 KB |
Output is correct |
9 |
Correct |
6 ms |
500 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
559 ms |
528 KB |
Output is correct |
12 |
Correct |
455 ms |
660 KB |
Output is correct |
13 |
Correct |
447 ms |
640 KB |
Output is correct |
14 |
Correct |
434 ms |
532 KB |
Output is correct |
15 |
Correct |
53 ms |
620 KB |
Output is correct |
16 |
Correct |
53 ms |
548 KB |
Output is correct |
17 |
Correct |
104 ms |
660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
830 ms |
544 KB |
Output is correct |
2 |
Correct |
616 ms |
416 KB |
Output is correct |
3 |
Correct |
553 ms |
532 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Correct |
4 ms |
500 KB |
Output is correct |
6 |
Correct |
0 ms |
500 KB |
Output is correct |
7 |
Correct |
523 ms |
524 KB |
Output is correct |
8 |
Correct |
794 ms |
416 KB |
Output is correct |
9 |
Correct |
681 ms |
416 KB |
Output is correct |
10 |
Correct |
562 ms |
420 KB |
Output is correct |
11 |
Correct |
6 ms |
492 KB |
Output is correct |
12 |
Correct |
6 ms |
500 KB |
Output is correct |
13 |
Correct |
4 ms |
492 KB |
Output is correct |
14 |
Correct |
4 ms |
500 KB |
Output is correct |
15 |
Correct |
2 ms |
492 KB |
Output is correct |
16 |
Correct |
459 ms |
512 KB |
Output is correct |
17 |
Correct |
525 ms |
536 KB |
Output is correct |
18 |
Correct |
469 ms |
528 KB |
Output is correct |
19 |
Correct |
447 ms |
420 KB |
Output is correct |
20 |
Correct |
466 ms |
528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
484 ms |
548 KB |
Partially correct |
2 |
Partially correct |
439 ms |
548 KB |
Partially correct |
3 |
Correct |
799 ms |
516 KB |
Output is correct |
4 |
Partially correct |
623 ms |
536 KB |
Partially correct |
5 |
Partially correct |
598 ms |
536 KB |
Partially correct |
6 |
Partially correct |
441 ms |
544 KB |
Partially correct |
7 |
Partially correct |
382 ms |
532 KB |
Partially correct |
8 |
Partially correct |
2 ms |
628 KB |
Partially correct |
9 |
Partially correct |
5 ms |
620 KB |
Partially correct |
10 |
Partially correct |
0 ms |
492 KB |
Partially correct |
11 |
Partially correct |
433 ms |
544 KB |
Partially correct |
12 |
Partially correct |
450 ms |
572 KB |
Partially correct |
13 |
Correct |
797 ms |
416 KB |
Output is correct |
14 |
Partially correct |
597 ms |
416 KB |
Partially correct |
15 |
Partially correct |
586 ms |
428 KB |
Partially correct |
16 |
Partially correct |
412 ms |
532 KB |
Partially correct |
17 |
Partially correct |
532 ms |
536 KB |
Partially correct |
18 |
Partially correct |
407 ms |
648 KB |
Partially correct |
19 |
Partially correct |
486 ms |
748 KB |
Partially correct |
20 |
Partially correct |
438 ms |
548 KB |
Partially correct |
21 |
Partially correct |
53 ms |
572 KB |
Partially correct |
22 |
Partially correct |
79 ms |
544 KB |
Partially correct |
23 |
Partially correct |
98 ms |
548 KB |
Partially correct |
24 |
Partially correct |
5 ms |
620 KB |
Partially correct |
25 |
Partially correct |
6 ms |
492 KB |
Partially correct |
26 |
Partially correct |
5 ms |
492 KB |
Partially correct |
27 |
Partially correct |
3 ms |
492 KB |
Partially correct |
28 |
Partially correct |
2 ms |
624 KB |
Partially correct |
29 |
Partially correct |
537 ms |
544 KB |
Partially correct |
30 |
Partially correct |
420 ms |
532 KB |
Partially correct |
31 |
Partially correct |
418 ms |
416 KB |
Partially correct |
32 |
Partially correct |
512 ms |
532 KB |
Partially correct |
33 |
Partially correct |
552 ms |
416 KB |
Partially correct |
34 |
Partially correct |
320 ms |
636 KB |
Partially correct |
35 |
Partially correct |
452 ms |
780 KB |
Partially correct |
36 |
Partially correct |
450 ms |
744 KB |
Partially correct |
37 |
Partially correct |
458 ms |
644 KB |
Partially correct |
38 |
Partially correct |
595 ms |
700 KB |
Partially correct |
39 |
Partially correct |
395 ms |
644 KB |
Partially correct |
40 |
Partially correct |
538 ms |
640 KB |
Partially correct |
41 |
Partially correct |
517 ms |
636 KB |
Partially correct |
42 |
Partially correct |
78 ms |
724 KB |
Partially correct |
43 |
Partially correct |
114 ms |
652 KB |
Partially correct |
44 |
Partially correct |
141 ms |
616 KB |
Partially correct |
45 |
Partially correct |
171 ms |
632 KB |
Partially correct |
46 |
Partially correct |
329 ms |
536 KB |
Partially correct |
47 |
Partially correct |
318 ms |
540 KB |
Partially correct |
48 |
Partially correct |
79 ms |
792 KB |
Partially correct |
49 |
Partially correct |
59 ms |
676 KB |
Partially correct |