#include "stations.h"
#include <vector>
#include <math.h>
#include <iostream>
#include <stdio.h>
using namespace std;
vector < int > Next[1005];
vector < int > how;
int con[1005]={0};
int ans[1005]={0};
int sz[1005]={0};
bool use[1005]={0};
int st;
void F(int here)
{
//printf("%d %d\n",here,con);
int now=0;
use[here]=1;
sz[here]=1;
how.push_back(here);
for(auto i:Next[here])
{
if(!use[i])
{
F(i);
sz[here]+=sz[i];
}
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
vector<int> labels;
how.clear();
int i;
for(i=0;i<n;i++)
{
labels.push_back(0);
Next[i].clear();
con[i]=0;
use[i]=0;
}
for(int i=0;i<n-1;i++)
{
Next[u[i]].push_back(v[i]);
Next[v[i]].push_back(u[i]);
}
F(0);
for(i=0;i<n;i++) labels[how[i]]=1000*i+(sz[how[i]]-1);
//for(i=0;i<n;i++) printf("%d ",labels[i]);
//printf("\n");
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
int x,n=c.size(),i;
//printf("%d %d %d\n",s,t,n);
if(n==1) return c[0];
if(t/1000>=s/1000+1&&t/1000<=s/1000+s%1000)
{
for(i=0;i<n;i++)
{
//printf("%d %d\n",s,c[i]);
if(c[i]/1000>s/1000)
{
if(t/1000>=c[i]/1000&&t/1000<=c[i]/1000+c[i]%1000) return c[i];
}
}
//return c[0];
}
else return c[0];
}
Compilation message
stations.cpp: In function 'void F(int)':
stations.cpp:17:9: warning: unused variable 'now' [-Wunused-variable]
17 | int now=0;
| ^~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:57:9: warning: unused variable 'x' [-Wunused-variable]
57 | int x,n=c.size(),i;
| ^
stations.cpp:74:1: warning: control reaches end of non-void function [-Wreturn-type]
74 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
512 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6003 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1510 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
643 ms |
1024 KB |
Output is correct |
2 |
Correct |
521 ms |
1024 KB |
Output is correct |
3 |
Correct |
976 ms |
864 KB |
Output is correct |
4 |
Correct |
658 ms |
868 KB |
Output is correct |
5 |
Correct |
676 ms |
876 KB |
Output is correct |
6 |
Correct |
517 ms |
1008 KB |
Output is correct |
7 |
Correct |
537 ms |
784 KB |
Output is correct |
8 |
Correct |
3 ms |
768 KB |
Output is correct |
9 |
Correct |
5 ms |
768 KB |
Output is correct |
10 |
Correct |
2 ms |
768 KB |
Output is correct |
11 |
Correct |
692 ms |
868 KB |
Output is correct |
12 |
Correct |
493 ms |
1008 KB |
Output is correct |
13 |
Correct |
622 ms |
1024 KB |
Output is correct |
14 |
Correct |
568 ms |
812 KB |
Output is correct |
15 |
Correct |
55 ms |
872 KB |
Output is correct |
16 |
Correct |
82 ms |
1144 KB |
Output is correct |
17 |
Correct |
131 ms |
800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
876 ms |
768 KB |
Output is correct |
2 |
Correct |
770 ms |
792 KB |
Output is correct |
3 |
Correct |
648 ms |
784 KB |
Output is correct |
4 |
Correct |
3 ms |
768 KB |
Output is correct |
5 |
Correct |
4 ms |
768 KB |
Output is correct |
6 |
Correct |
2 ms |
868 KB |
Output is correct |
7 |
Correct |
611 ms |
1040 KB |
Output is correct |
8 |
Correct |
875 ms |
1032 KB |
Output is correct |
9 |
Correct |
667 ms |
768 KB |
Output is correct |
10 |
Correct |
603 ms |
792 KB |
Output is correct |
11 |
Correct |
6 ms |
996 KB |
Output is correct |
12 |
Correct |
7 ms |
896 KB |
Output is correct |
13 |
Correct |
5 ms |
868 KB |
Output is correct |
14 |
Correct |
3 ms |
872 KB |
Output is correct |
15 |
Correct |
2 ms |
868 KB |
Output is correct |
16 |
Correct |
582 ms |
864 KB |
Output is correct |
17 |
Correct |
532 ms |
868 KB |
Output is correct |
18 |
Correct |
578 ms |
768 KB |
Output is correct |
19 |
Correct |
606 ms |
876 KB |
Output is correct |
20 |
Correct |
525 ms |
880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
637 ms |
1024 KB |
Partially correct |
2 |
Partially correct |
460 ms |
1012 KB |
Partially correct |
3 |
Correct |
865 ms |
1024 KB |
Output is correct |
4 |
Partially correct |
679 ms |
768 KB |
Partially correct |
5 |
Partially correct |
578 ms |
872 KB |
Partially correct |
6 |
Partially correct |
471 ms |
776 KB |
Partially correct |
7 |
Partially correct |
442 ms |
788 KB |
Partially correct |
8 |
Partially correct |
2 ms |
872 KB |
Partially correct |
9 |
Partially correct |
4 ms |
868 KB |
Partially correct |
10 |
Partially correct |
1 ms |
868 KB |
Partially correct |
11 |
Partially correct |
461 ms |
800 KB |
Partially correct |
12 |
Partially correct |
555 ms |
808 KB |
Partially correct |
13 |
Correct |
849 ms |
768 KB |
Output is correct |
14 |
Partially correct |
636 ms |
872 KB |
Partially correct |
15 |
Partially correct |
627 ms |
768 KB |
Partially correct |
16 |
Partially correct |
443 ms |
768 KB |
Partially correct |
17 |
Partially correct |
606 ms |
1172 KB |
Partially correct |
18 |
Partially correct |
466 ms |
768 KB |
Partially correct |
19 |
Partially correct |
472 ms |
1136 KB |
Partially correct |
20 |
Partially correct |
449 ms |
808 KB |
Partially correct |
21 |
Partially correct |
57 ms |
768 KB |
Partially correct |
22 |
Partially correct |
75 ms |
820 KB |
Partially correct |
23 |
Partially correct |
112 ms |
1024 KB |
Partially correct |
24 |
Partially correct |
7 ms |
768 KB |
Partially correct |
25 |
Partially correct |
6 ms |
768 KB |
Partially correct |
26 |
Partially correct |
7 ms |
868 KB |
Partially correct |
27 |
Partially correct |
5 ms |
768 KB |
Partially correct |
28 |
Partially correct |
2 ms |
872 KB |
Partially correct |
29 |
Partially correct |
543 ms |
1024 KB |
Partially correct |
30 |
Partially correct |
636 ms |
832 KB |
Partially correct |
31 |
Partially correct |
528 ms |
768 KB |
Partially correct |
32 |
Partially correct |
579 ms |
1040 KB |
Partially correct |
33 |
Partially correct |
490 ms |
876 KB |
Partially correct |
34 |
Partially correct |
316 ms |
780 KB |
Partially correct |
35 |
Partially correct |
472 ms |
1024 KB |
Partially correct |
36 |
Partially correct |
428 ms |
1024 KB |
Partially correct |
37 |
Partially correct |
549 ms |
904 KB |
Partially correct |
38 |
Partially correct |
571 ms |
888 KB |
Partially correct |
39 |
Partially correct |
555 ms |
1024 KB |
Partially correct |
40 |
Partially correct |
517 ms |
1012 KB |
Partially correct |
41 |
Partially correct |
552 ms |
880 KB |
Partially correct |
42 |
Partially correct |
83 ms |
768 KB |
Partially correct |
43 |
Partially correct |
121 ms |
784 KB |
Partially correct |
44 |
Partially correct |
143 ms |
908 KB |
Partially correct |
45 |
Partially correct |
185 ms |
832 KB |
Partially correct |
46 |
Partially correct |
340 ms |
800 KB |
Partially correct |
47 |
Partially correct |
415 ms |
788 KB |
Partially correct |
48 |
Partially correct |
86 ms |
1024 KB |
Partially correct |
49 |
Partially correct |
79 ms |
1024 KB |
Partially correct |