# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1052378 | 2024-08-10T14:05:13 Z | noyancanturk | Stations (IOI20_stations) | C++17 | 521 ms | 1456 KB |
#include "stations.h" #include<bits/stdc++.h> using namespace std; #define pb push_back const int lim=2000; vector<int>v[lim]; int sz[lim]; int sbs(int node,int par){ sz[node]=1; for(int j:v[node]){ if(j==par)continue; sz[node]+=sbs(j,node); } return sz[node]; } vector<int>labels; void dfs(int node,int par,int l,int r,bool tag){ //cerr<<node<<" "<<par<<" "<<l<<" "<<r<<"\n"; assert(node<labels.size()); labels[node]=tag?l:r; int past=tag; for(int j:v[node]){ if(j==par)continue; dfs(j,node,l+past,l+past+sz[j]-1,!tag); past+=sz[j]; } } std::vector<int> label(int n, int k, std::vector<int> U, std::vector<int> V) { for(int i=0;i<n;i++)v[i].clear(); for(int i=0;i<n-1;i++){ v[U[i]].pb(V[i]); v[V[i]].pb(U[i]); } labels=vector<int>(n); sbs(0,-1); dfs(0,-1,0,n-1,1); /* for(int i=0;i<n;i++)cerr<<labels[i]<<" "; cerr<<"\n"; */ return labels; } int find_next_station(int s, int t, std::vector<int> c) { if(s<c[0]){ for(int i=0;i+1<c.size();i++){ if(s<=t&&t<=c[i]){ return c[i]; } } return c[c.size()-1]; }else{ for(int i=int(c.size())-1;i;i--){ if(c[i]<=t&&t<=s){ return c[i]; } } return c[0]; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 300 ms | 940 KB | Output is correct |
2 | Correct | 254 ms | 944 KB | Output is correct |
3 | Correct | 491 ms | 684 KB | Output is correct |
4 | Correct | 379 ms | 680 KB | Output is correct |
5 | Correct | 360 ms | 684 KB | Output is correct |
6 | Correct | 234 ms | 940 KB | Output is correct |
7 | Correct | 252 ms | 684 KB | Output is correct |
8 | Correct | 1 ms | 776 KB | Output is correct |
9 | Correct | 2 ms | 776 KB | Output is correct |
10 | Correct | 0 ms | 776 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 239 ms | 684 KB | Output is correct |
2 | Correct | 289 ms | 684 KB | Output is correct |
3 | Correct | 521 ms | 684 KB | Output is correct |
4 | Correct | 352 ms | 684 KB | Output is correct |
5 | Correct | 313 ms | 684 KB | Output is correct |
6 | Correct | 262 ms | 684 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 307 ms | 940 KB | Output is correct |
2 | Correct | 299 ms | 940 KB | Output is correct |
3 | Correct | 504 ms | 684 KB | Output is correct |
4 | Correct | 375 ms | 684 KB | Output is correct |
5 | Correct | 315 ms | 684 KB | Output is correct |
6 | Correct | 217 ms | 940 KB | Output is correct |
7 | Correct | 270 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 | 808 KB | Output is correct |
11 | Correct | 355 ms | 824 KB | Output is correct |
12 | Correct | 264 ms | 1068 KB | Output is correct |
13 | Correct | 260 ms | 940 KB | Output is correct |
14 | Correct | 222 ms | 684 KB | Output is correct |
15 | Correct | 23 ms | 764 KB | Output is correct |
16 | Correct | 27 ms | 768 KB | Output is correct |
17 | Correct | 46 ms | 940 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 471 ms | 688 KB | Output is correct |
2 | Correct | 376 ms | 684 KB | Output is correct |
3 | Correct | 348 ms | 684 KB | Output is correct |
4 | Correct | 1 ms | 896 KB | Output is correct |
5 | Correct | 2 ms | 776 KB | Output is correct |
6 | Correct | 0 ms | 768 KB | Output is correct |
7 | Correct | 315 ms | 684 KB | Output is correct |
8 | Correct | 435 ms | 684 KB | Output is correct |
9 | Correct | 355 ms | 684 KB | Output is correct |
10 | Correct | 354 ms | 684 KB | Output is correct |
11 | Correct | 2 ms | 768 KB | Output is correct |
12 | Correct | 3 ms | 768 KB | Output is correct |
13 | Correct | 3 ms | 768 KB | Output is correct |
14 | Correct | 2 ms | 760 KB | Output is correct |
15 | Correct | 0 ms | 768 KB | Output is correct |
16 | Correct | 262 ms | 684 KB | Output is correct |
17 | Correct | 249 ms | 684 KB | Output is correct |
18 | Correct | 275 ms | 684 KB | Output is correct |
19 | Correct | 282 ms | 688 KB | Output is correct |
20 | Correct | 272 ms | 936 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 274 ms | 940 KB | Output is correct |
2 | Correct | 246 ms | 956 KB | Output is correct |
3 | Correct | 457 ms | 860 KB | Output is correct |
4 | Correct | 391 ms | 684 KB | Output is correct |
5 | Correct | 293 ms | 868 KB | Output is correct |
6 | Correct | 253 ms | 940 KB | Output is correct |
7 | Correct | 263 ms | 684 KB | Output is correct |
8 | Correct | 2 ms | 764 KB | Output is correct |
9 | Correct | 2 ms | 768 KB | Output is correct |
10 | Correct | 1 ms | 764 KB | Output is correct |
11 | Correct | 244 ms | 684 KB | Output is correct |
12 | Correct | 267 ms | 688 KB | Output is correct |
13 | Correct | 415 ms | 684 KB | Output is correct |
14 | Correct | 383 ms | 684 KB | Output is correct |
15 | Correct | 346 ms | 684 KB | Output is correct |
16 | Correct | 271 ms | 684 KB | Output is correct |
17 | Correct | 330 ms | 684 KB | Output is correct |
18 | Correct | 268 ms | 1188 KB | Output is correct |
19 | Correct | 247 ms | 1064 KB | Output is correct |
20 | Correct | 234 ms | 684 KB | Output is correct |
21 | Correct | 30 ms | 768 KB | Output is correct |
22 | Correct | 46 ms | 876 KB | Output is correct |
23 | Correct | 59 ms | 940 KB | Output is correct |
24 | Correct | 3 ms | 768 KB | Output is correct |
25 | Correct | 2 ms | 764 KB | Output is correct |
26 | Correct | 3 ms | 768 KB | Output is correct |
27 | Correct | 3 ms | 768 KB | Output is correct |
28 | Correct | 1 ms | 768 KB | Output is correct |
29 | Correct | 297 ms | 684 KB | Output is correct |
30 | Correct | 292 ms | 684 KB | Output is correct |
31 | Correct | 299 ms | 684 KB | Output is correct |
32 | Correct | 265 ms | 684 KB | Output is correct |
33 | Correct | 294 ms | 820 KB | Output is correct |
34 | Correct | 181 ms | 1456 KB | Output is correct |
35 | Correct | 249 ms | 1084 KB | Output is correct |
36 | Correct | 276 ms | 1204 KB | Output is correct |
37 | Correct | 270 ms | 812 KB | Output is correct |
38 | Correct | 264 ms | 1188 KB | Output is correct |
39 | Correct | 261 ms | 1352 KB | Output is correct |
40 | Correct | 263 ms | 1196 KB | Output is correct |
41 | Correct | 244 ms | 820 KB | Output is correct |
42 | Correct | 37 ms | 736 KB | Output is correct |
43 | Correct | 49 ms | 684 KB | Output is correct |
44 | Correct | 79 ms | 740 KB | Output is correct |
45 | Correct | 94 ms | 888 KB | Output is correct |
46 | Correct | 148 ms | 684 KB | Output is correct |
47 | Correct | 188 ms | 684 KB | Output is correct |
48 | Correct | 36 ms | 1196 KB | Output is correct |
49 | Correct | 34 ms | 1180 KB | Output is correct |