Submission #604685

# Submission time Handle Problem Language Result Execution time Memory
604685 2022-07-25T08:47:01 Z rrrr10000 Stations (IOI20_stations) C++14
100 / 100
1095 ms 800 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define pb emplace_back
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}

vector<int> label(int n,int k,vector<int> a,vector<int> b){
    vvi g(n);
    rep(i,n-1){
        g[a[i]].pb(b[i]);g[b[i]].pb(a[i]);
    }
    vp dp(n);
    dp[0]=P(0,n-1);
    vector<int> res(n);
    vi sub(n,1);
    function<ll(ll,ll)> dfs0=[&](ll i,ll p){
        for(ll x:g[i])if(x!=p)sub[i]+=dfs0(x,i);
        return sub[i];
    };dfs0(0,-1);
    function<void(ll,ll,ll)> dfs1=[&](ll i,ll p,ll d){
        if(d%2)res[i]=dp[i].fi++;
        else res[i]=dp[i].se--;
        for(ll x:g[i])if(x!=p){
            dp[x]=P(dp[i].fi,dp[i].fi+sub[x]-1);
            dp[i].fi+=sub[x];
            dfs1(x,i,d+1);
        }
    };dfs1(0,-1,0);
    return res;
}
int find_next_station(int s,int t,vector<int> c){
    for(int x:c)if(x==t)return t;
    if(c.size()==1)return c[0];
    if(s<c[0]){
        if(t<s||t>c.back())return c.back();
        rep(i,c.size())if(c[i]>t)return c[i];
    }
    if(t>s||t<c[0])return c[0];
    for(int i=c.size()-1;i>=0;i--)if(c[i]<t)return c[i];
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 506 ms 620 KB Output is correct
2 Correct 368 ms 628 KB Output is correct
3 Correct 904 ms 484 KB Output is correct
4 Correct 719 ms 528 KB Output is correct
5 Correct 625 ms 520 KB Output is correct
6 Correct 397 ms 664 KB Output is correct
7 Correct 500 ms 704 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 6 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 540 ms 484 KB Output is correct
2 Correct 747 ms 516 KB Output is correct
3 Correct 1063 ms 552 KB Output is correct
4 Correct 817 ms 568 KB Output is correct
5 Correct 665 ms 484 KB Output is correct
6 Correct 650 ms 660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 532 ms 704 KB Output is correct
2 Correct 525 ms 692 KB Output is correct
3 Correct 981 ms 484 KB Output is correct
4 Correct 726 ms 416 KB Output is correct
5 Correct 580 ms 500 KB Output is correct
6 Correct 500 ms 748 KB Output is correct
7 Correct 529 ms 632 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 5 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 694 ms 420 KB Output is correct
12 Correct 640 ms 800 KB Output is correct
13 Correct 492 ms 712 KB Output is correct
14 Correct 442 ms 496 KB Output is correct
15 Correct 35 ms 472 KB Output is correct
16 Correct 67 ms 600 KB Output is correct
17 Correct 130 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1095 ms 480 KB Output is correct
2 Correct 640 ms 504 KB Output is correct
3 Correct 656 ms 548 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 5 ms 444 KB Output is correct
6 Correct 1 ms 416 KB Output is correct
7 Correct 687 ms 464 KB Output is correct
8 Correct 827 ms 416 KB Output is correct
9 Correct 756 ms 460 KB Output is correct
10 Correct 695 ms 484 KB Output is correct
11 Correct 3 ms 492 KB Output is correct
12 Correct 4 ms 492 KB Output is correct
13 Correct 5 ms 564 KB Output is correct
14 Correct 3 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 446 ms 420 KB Output is correct
17 Correct 667 ms 608 KB Output is correct
18 Correct 497 ms 520 KB Output is correct
19 Correct 496 ms 416 KB Output is correct
20 Correct 533 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 530 ms 612 KB Output is correct
2 Correct 536 ms 676 KB Output is correct
3 Correct 1043 ms 488 KB Output is correct
4 Correct 846 ms 504 KB Output is correct
5 Correct 571 ms 416 KB Output is correct
6 Correct 524 ms 620 KB Output is correct
7 Correct 506 ms 632 KB Output is correct
8 Correct 6 ms 500 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 556 ms 504 KB Output is correct
12 Correct 655 ms 548 KB Output is correct
13 Correct 928 ms 552 KB Output is correct
14 Correct 790 ms 504 KB Output is correct
15 Correct 661 ms 416 KB Output is correct
16 Correct 508 ms 536 KB Output is correct
17 Correct 644 ms 484 KB Output is correct
18 Correct 515 ms 712 KB Output is correct
19 Correct 565 ms 784 KB Output is correct
20 Correct 475 ms 544 KB Output is correct
21 Correct 81 ms 416 KB Output is correct
22 Correct 64 ms 544 KB Output is correct
23 Correct 128 ms 612 KB Output is correct
24 Correct 3 ms 468 KB Output is correct
25 Correct 5 ms 440 KB Output is correct
26 Correct 4 ms 492 KB Output is correct
27 Correct 3 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 714 ms 416 KB Output is correct
30 Correct 529 ms 504 KB Output is correct
31 Correct 517 ms 568 KB Output is correct
32 Correct 579 ms 416 KB Output is correct
33 Correct 460 ms 420 KB Output is correct
34 Correct 330 ms 672 KB Output is correct
35 Correct 469 ms 720 KB Output is correct
36 Correct 576 ms 780 KB Output is correct
37 Correct 538 ms 708 KB Output is correct
38 Correct 484 ms 676 KB Output is correct
39 Correct 420 ms 628 KB Output is correct
40 Correct 346 ms 712 KB Output is correct
41 Correct 430 ms 748 KB Output is correct
42 Correct 58 ms 652 KB Output is correct
43 Correct 113 ms 548 KB Output is correct
44 Correct 112 ms 572 KB Output is correct
45 Correct 168 ms 568 KB Output is correct
46 Correct 318 ms 628 KB Output is correct
47 Correct 317 ms 632 KB Output is correct
48 Correct 53 ms 548 KB Output is correct
49 Correct 66 ms 600 KB Output is correct