# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
377916 | 2021-03-15T14:31:17 Z | Thistle | Stations (IOI20_stations) | C++14 | 1051 ms | 1304 KB |
#include "stations.h" #include <vector> #include<iostream> #include<algorithm> using namespace std; using ll=long long; using H=pair<ll, ll>; using vi=vector<ll>; #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define rep(i,n) rng((i),(0),(n)) #define pb push_back #define vec vector #define all(a) (a).begin(),(a).end() #define fs first #define sc second #define siz(a) ll((a).size()) std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { vec<vi>e(n); rep(i,n-1){ e[u[i]].pb(v[i]); e[v[i]].pb(u[i]); } vi in(n),out(n),dpt(n,0); int idx=0; auto dfs=[&](int x,int p,int d,auto& dfs)->void{ in[x]=idx++; dpt[x]=d; for(auto g:e[x]){ if(g==p) continue; dfs(g,x,d+1,dfs); } out[x]=idx++; }; dfs(0,-1,0,dfs); std::vector<int> labels(n); for (int i = 0; i < n; i++) { if(!(dpt[i]&1)){ labels[i]=in[i]; } else{ labels[i]=out[i]; } } vec<int>tmp=labels; sort(all(tmp)); tmp.erase(unique(all(tmp)),tmp.end()); for(auto& g:labels){ g=lower_bound(all(tmp),g)-tmp.begin(); } return labels; } int find_next_station(int s, int t, std::vector<int> c) { int mx=-10000,mn=10000; for(auto g:c){ mx=max(mx,g); mn=min(mn,g); } //subete no kodomo no kukan wo motomeru vec<H>itv(siz(c),H{-1,-1}); int root=-1; if(mx<s){ //saishou no yatu ga ne root=mn; sort(all(c)); c.erase(c.begin()); //kore de ne igai ni natta rep(i,siz(c)){ itv[i].fs=c[i]; if(i<siz(c)-1) itv[i].sc=c[i+1]; else itv[i].sc=s; } } else{ if(s!=0) root=mx; sort(all(c)); if(c.back()==root) c.erase(prev(c.end())); rep(i,siz(c)){ if(i==0) itv[i].fs=s+1; else itv[i].fs=c[i-1]+1; itv[i].sc=c[i]+1; } } rep(i,siz(c)){ if(itv[i].fs<=t&&t<itv[i].sc){ return c[i]; } } return root; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 678 ms | 884 KB | Output is correct |
2 | Correct | 537 ms | 1076 KB | Output is correct |
3 | Correct | 873 ms | 756 KB | Output is correct |
4 | Correct | 749 ms | 736 KB | Output is correct |
5 | Correct | 793 ms | 868 KB | Output is correct |
6 | Correct | 598 ms | 956 KB | Output is correct |
7 | Correct | 588 ms | 976 KB | Output is correct |
8 | Correct | 3 ms | 876 KB | Output is correct |
9 | Correct | 4 ms | 756 KB | Output is correct |
10 | Correct | 2 ms | 756 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 507 ms | 884 KB | Output is correct |
2 | Correct | 565 ms | 1044 KB | Output is correct |
3 | Correct | 986 ms | 884 KB | Output is correct |
4 | Correct | 791 ms | 736 KB | Output is correct |
5 | Correct | 672 ms | 756 KB | Output is correct |
6 | Correct | 546 ms | 764 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 644 ms | 884 KB | Output is correct |
2 | Correct | 438 ms | 884 KB | Output is correct |
3 | Correct | 1051 ms | 868 KB | Output is correct |
4 | Correct | 859 ms | 736 KB | Output is correct |
5 | Correct | 696 ms | 868 KB | Output is correct |
6 | Correct | 486 ms | 1012 KB | Output is correct |
7 | Correct | 537 ms | 884 KB | Output is correct |
8 | Correct | 3 ms | 736 KB | Output is correct |
9 | Correct | 4 ms | 876 KB | Output is correct |
10 | Correct | 2 ms | 756 KB | Output is correct |
11 | Correct | 675 ms | 756 KB | Output is correct |
12 | Correct | 504 ms | 1044 KB | Output is correct |
13 | Correct | 507 ms | 1120 KB | Output is correct |
14 | Correct | 437 ms | 756 KB | Output is correct |
15 | Correct | 54 ms | 756 KB | Output is correct |
16 | Correct | 68 ms | 808 KB | Output is correct |
17 | Correct | 119 ms | 864 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 995 ms | 756 KB | Output is correct |
2 | Correct | 737 ms | 868 KB | Output is correct |
3 | Correct | 735 ms | 868 KB | Output is correct |
4 | Correct | 3 ms | 868 KB | Output is correct |
5 | Correct | 5 ms | 756 KB | Output is correct |
6 | Correct | 2 ms | 736 KB | Output is correct |
7 | Correct | 628 ms | 756 KB | Output is correct |
8 | Correct | 948 ms | 736 KB | Output is correct |
9 | Correct | 643 ms | 1004 KB | Output is correct |
10 | Correct | 639 ms | 868 KB | Output is correct |
11 | Correct | 7 ms | 868 KB | Output is correct |
12 | Correct | 7 ms | 876 KB | Output is correct |
13 | Correct | 4 ms | 776 KB | Output is correct |
14 | Correct | 3 ms | 876 KB | Output is correct |
15 | Correct | 2 ms | 864 KB | Output is correct |
16 | Correct | 494 ms | 884 KB | Output is correct |
17 | Correct | 550 ms | 868 KB | Output is correct |
18 | Correct | 577 ms | 736 KB | Output is correct |
19 | Correct | 609 ms | 868 KB | Output is correct |
20 | Correct | 510 ms | 1072 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 646 ms | 944 KB | Output is correct |
2 | Correct | 483 ms | 960 KB | Output is correct |
3 | Correct | 1012 ms | 1012 KB | Output is correct |
4 | Correct | 695 ms | 756 KB | Output is correct |
5 | Correct | 569 ms | 868 KB | Output is correct |
6 | Correct | 535 ms | 940 KB | Output is correct |
7 | Correct | 504 ms | 864 KB | Output is correct |
8 | Correct | 3 ms | 736 KB | Output is correct |
9 | Correct | 5 ms | 736 KB | Output is correct |
10 | Correct | 2 ms | 876 KB | Output is correct |
11 | Correct | 458 ms | 736 KB | Output is correct |
12 | Correct | 572 ms | 976 KB | Output is correct |
13 | Correct | 1018 ms | 736 KB | Output is correct |
14 | Correct | 857 ms | 756 KB | Output is correct |
15 | Correct | 579 ms | 736 KB | Output is correct |
16 | Correct | 507 ms | 772 KB | Output is correct |
17 | Correct | 625 ms | 736 KB | Output is correct |
18 | Correct | 484 ms | 968 KB | Output is correct |
19 | Correct | 653 ms | 1052 KB | Output is correct |
20 | Correct | 644 ms | 768 KB | Output is correct |
21 | Correct | 71 ms | 864 KB | Output is correct |
22 | Correct | 92 ms | 756 KB | Output is correct |
23 | Correct | 106 ms | 872 KB | Output is correct |
24 | Correct | 5 ms | 736 KB | Output is correct |
25 | Correct | 5 ms | 916 KB | Output is correct |
26 | Correct | 5 ms | 756 KB | Output is correct |
27 | Correct | 3 ms | 736 KB | Output is correct |
28 | Correct | 2 ms | 908 KB | Output is correct |
29 | Correct | 584 ms | 736 KB | Output is correct |
30 | Correct | 642 ms | 756 KB | Output is correct |
31 | Correct | 568 ms | 736 KB | Output is correct |
32 | Correct | 623 ms | 884 KB | Output is correct |
33 | Correct | 628 ms | 868 KB | Output is correct |
34 | Correct | 354 ms | 876 KB | Output is correct |
35 | Correct | 480 ms | 1164 KB | Output is correct |
36 | Correct | 448 ms | 1060 KB | Output is correct |
37 | Correct | 655 ms | 864 KB | Output is correct |
38 | Correct | 660 ms | 1248 KB | Output is correct |
39 | Correct | 444 ms | 1244 KB | Output is correct |
40 | Correct | 477 ms | 1304 KB | Output is correct |
41 | Correct | 643 ms | 1120 KB | Output is correct |
42 | Correct | 65 ms | 736 KB | Output is correct |
43 | Correct | 118 ms | 864 KB | Output is correct |
44 | Correct | 189 ms | 756 KB | Output is correct |
45 | Correct | 222 ms | 864 KB | Output is correct |
46 | Correct | 448 ms | 808 KB | Output is correct |
47 | Correct | 364 ms | 1000 KB | Output is correct |
48 | Correct | 81 ms | 1104 KB | Output is correct |
49 | Correct | 82 ms | 992 KB | Output is correct |