#include "bits/stdc++.h"
#include "stations.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
const int N = 1005;
vector<int> v[N];
int tin[N],tout[N],col[N],ti=0;
void dfs(int c,int p,int d){
tin[c]=++ti;
for(int x:v[c]){
if(x==p) continue;
dfs(x,c,d^1);
tout[c]=max(tout[c],tout[x]);
}
tout[c]=++ti;
if(d) col[c]=tin[c];
else col[c]=tout[c];
}
vector<int> label(int n, int k, vector<int> u, vector<int> g){
ti=0;
for(int i=0;i<n;i++) v[i].clear();
vector<int> labels(n);
for(int i=0;i<n-1;i++){
int a=u[i],b=g[i];
v[a].push_back(b);
v[b].push_back(a);
}
dfs(0,0,0);
map<int,int> mp;
for(int i=0;i<n;i++) mp[col[i]]=1;
int p=0;
for(auto x:mp) mp[x.first]=++p;
for(int i=0;i<n;i++) labels[i]=mp[col[i]];
return labels;
}
int find_next_station(int s, int t, vector<int> c){
sort(all(c));
int n=sz(c);
if(n==1) return c[0];
if(s<c[0]){
int out=c[n-2];
if(!(t>=s && t<=out)) return c[n-1];
int in=s;
for(int i=0;i<n-1;i++){
if(t>=in && t<=c[i]) return c[i];
in=c[i];
}
return c[n-1];
}
int in=c[1];
if(!(t>=in && t<=s)) return c[0];
int out=s;
for(int i=n-1;i>0;i--){
if(t>=c[i] && t<=out) return c[i];
out=c[i];
}
return 2323232323;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
315 ms |
940 KB |
Output is correct |
2 |
Correct |
234 ms |
940 KB |
Output is correct |
3 |
Correct |
508 ms |
684 KB |
Output is correct |
4 |
Correct |
363 ms |
684 KB |
Output is correct |
5 |
Correct |
322 ms |
684 KB |
Output is correct |
6 |
Correct |
235 ms |
940 KB |
Output is correct |
7 |
Correct |
238 ms |
940 KB |
Output is correct |
8 |
Correct |
1 ms |
776 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
248 ms |
684 KB |
Output is correct |
2 |
Correct |
296 ms |
684 KB |
Output is correct |
3 |
Correct |
511 ms |
684 KB |
Output is correct |
4 |
Correct |
380 ms |
684 KB |
Output is correct |
5 |
Correct |
339 ms |
684 KB |
Output is correct |
6 |
Correct |
227 ms |
688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
302 ms |
940 KB |
Output is correct |
2 |
Correct |
265 ms |
940 KB |
Output is correct |
3 |
Correct |
499 ms |
684 KB |
Output is correct |
4 |
Correct |
343 ms |
684 KB |
Output is correct |
5 |
Correct |
331 ms |
684 KB |
Output is correct |
6 |
Correct |
284 ms |
940 KB |
Output is correct |
7 |
Correct |
264 ms |
940 KB |
Output is correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
776 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
361 ms |
684 KB |
Output is correct |
12 |
Correct |
247 ms |
1048 KB |
Output is correct |
13 |
Correct |
258 ms |
1052 KB |
Output is correct |
14 |
Correct |
253 ms |
684 KB |
Output is correct |
15 |
Correct |
21 ms |
768 KB |
Output is correct |
16 |
Correct |
28 ms |
768 KB |
Output is correct |
17 |
Correct |
51 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
502 ms |
684 KB |
Output is correct |
2 |
Correct |
368 ms |
684 KB |
Output is correct |
3 |
Correct |
377 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
764 KB |
Output is correct |
6 |
Correct |
0 ms |
760 KB |
Output is correct |
7 |
Correct |
323 ms |
800 KB |
Output is correct |
8 |
Correct |
467 ms |
680 KB |
Output is correct |
9 |
Correct |
353 ms |
684 KB |
Output is correct |
10 |
Correct |
342 ms |
680 KB |
Output is correct |
11 |
Correct |
1 ms |
764 KB |
Output is correct |
12 |
Correct |
3 ms |
768 KB |
Output is correct |
13 |
Correct |
1 ms |
768 KB |
Output is correct |
14 |
Correct |
1 ms |
776 KB |
Output is correct |
15 |
Correct |
1 ms |
776 KB |
Output is correct |
16 |
Correct |
272 ms |
800 KB |
Output is correct |
17 |
Correct |
301 ms |
684 KB |
Output is correct |
18 |
Correct |
291 ms |
684 KB |
Output is correct |
19 |
Correct |
297 ms |
684 KB |
Output is correct |
20 |
Correct |
304 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
297 ms |
940 KB |
Output is correct |
2 |
Correct |
252 ms |
940 KB |
Output is correct |
3 |
Correct |
509 ms |
684 KB |
Output is correct |
4 |
Correct |
393 ms |
684 KB |
Output is correct |
5 |
Correct |
325 ms |
684 KB |
Output is correct |
6 |
Correct |
264 ms |
940 KB |
Output is correct |
7 |
Correct |
243 ms |
684 KB |
Output is correct |
8 |
Correct |
0 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
764 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
260 ms |
688 KB |
Output is correct |
12 |
Correct |
304 ms |
684 KB |
Output is correct |
13 |
Correct |
543 ms |
684 KB |
Output is correct |
14 |
Correct |
340 ms |
684 KB |
Output is correct |
15 |
Correct |
330 ms |
684 KB |
Output is correct |
16 |
Correct |
251 ms |
684 KB |
Output is correct |
17 |
Correct |
331 ms |
688 KB |
Output is correct |
18 |
Correct |
251 ms |
1188 KB |
Output is correct |
19 |
Correct |
259 ms |
1044 KB |
Output is correct |
20 |
Correct |
240 ms |
684 KB |
Output is correct |
21 |
Correct |
21 ms |
764 KB |
Output is correct |
22 |
Correct |
31 ms |
768 KB |
Output is correct |
23 |
Correct |
48 ms |
788 KB |
Output is correct |
24 |
Correct |
3 ms |
776 KB |
Output is correct |
25 |
Correct |
3 ms |
768 KB |
Output is correct |
26 |
Correct |
2 ms |
768 KB |
Output is correct |
27 |
Correct |
2 ms |
768 KB |
Output is correct |
28 |
Correct |
1 ms |
776 KB |
Output is correct |
29 |
Correct |
309 ms |
684 KB |
Output is correct |
30 |
Correct |
274 ms |
684 KB |
Output is correct |
31 |
Correct |
306 ms |
684 KB |
Output is correct |
32 |
Correct |
265 ms |
684 KB |
Output is correct |
33 |
Correct |
281 ms |
684 KB |
Output is correct |
34 |
Correct |
176 ms |
940 KB |
Output is correct |
35 |
Correct |
248 ms |
940 KB |
Output is correct |
36 |
Correct |
235 ms |
1056 KB |
Output is correct |
37 |
Correct |
237 ms |
1048 KB |
Output is correct |
38 |
Correct |
279 ms |
1296 KB |
Output is correct |
39 |
Correct |
240 ms |
1048 KB |
Output is correct |
40 |
Correct |
235 ms |
1188 KB |
Output is correct |
41 |
Correct |
273 ms |
1052 KB |
Output is correct |
42 |
Correct |
28 ms |
764 KB |
Output is correct |
43 |
Correct |
57 ms |
744 KB |
Output is correct |
44 |
Correct |
67 ms |
768 KB |
Output is correct |
45 |
Correct |
67 ms |
688 KB |
Output is correct |
46 |
Correct |
185 ms |
684 KB |
Output is correct |
47 |
Correct |
168 ms |
972 KB |
Output is correct |
48 |
Correct |
28 ms |
1024 KB |
Output is correct |
49 |
Correct |
32 ms |
1280 KB |
Output is correct |