Submission #305093

# Submission time Handle Problem Language Result Execution time Memory
305093 2020-09-22T14:53:16 Z Theo830 Stations (IOI20_stations) C++14
100 / 100
1180 ms 1136 KB
#include <bits/stdc++.h>

using namespace std;

typedef int ll;

#define f(i,a,b) for(ll i = a;i < b;i++)

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define vll vector<ll>

#define pb push_back

///I hope I will get uprating and don't make mistakes

///I will never stop programming

///sqrt(-1) Love C++

///Please don't hack me

///@TheofanisOrfanou Theo830

///Training

vector<vll>adj;

ll tim = 0;

ll tin[1005];

ll tout[1005];

ll depth[1005];

void solve(ll s,ll p){

    tin[s] = tim;

    if(depth[s] % 2 == 0){

        tim++;

    }

    for(auto x:adj[s]){

        if(x != p){

            depth[x] = depth[s] + 1;

            solve(x,s);

        }

    }

    tout[s] = tim;

    if(depth[s] % 2){

        tim++;

    }

}
vector<int> label(int n, int k,vector<int> u,vector<int> v) {
    vector<int> labels(n);

    ll m = u.size();

    adj.assign(n+5,vll());

    f(i,0,m){

        adj[u[i]].pb(v[i]);

        adj[v[i]].pb(u[i]);

    }

    tim = 0;

    depth[0] = 0;

    solve(0,-1);

    f(i,0,n){

        if(depth[i] % 2 == 0){

            labels[i] = tin[i];

        }

        else{

            labels[i] = tout[i];

        }

    }

    return labels;
}

bool isin(ll l,ll r,ll x){

    return (l <= x && x <= r);

}
int find_next_station(int s,int t,vector<int> c){

    ll tins,touts;

    if(s < c[0]){

        tins = s;

        touts = c.back();

        if(!isin(tins,touts,t)){

            return c.back();

        }

        else{

            for(auto x:c){

                if(t <= x){

                    return x;

                }

            }

        }

    }

    else{

        touts = s;

        tins = c[0];

        if(!isin(tins,touts,t)){

            return c[0];

        }

        else{

            reverse(c.begin(),c.end());

            for(auto x:c){

                if(x <= t){

                    return x;

                }

            }

        }

    }

    assert(0);
}
# Verdict Execution time Memory Grader output
1 Correct 745 ms 832 KB Output is correct
2 Correct 529 ms 1024 KB Output is correct
3 Correct 1049 ms 800 KB Output is correct
4 Correct 719 ms 768 KB Output is correct
5 Correct 633 ms 880 KB Output is correct
6 Correct 522 ms 768 KB Output is correct
7 Correct 511 ms 760 KB Output is correct
8 Correct 3 ms 896 KB Output is correct
9 Correct 4 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 616 ms 1024 KB Output is correct
2 Correct 703 ms 896 KB Output is correct
3 Correct 1089 ms 896 KB Output is correct
4 Correct 846 ms 888 KB Output is correct
5 Correct 790 ms 924 KB Output is correct
6 Correct 588 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 628 ms 1032 KB Output is correct
2 Correct 440 ms 1008 KB Output is correct
3 Correct 1170 ms 768 KB Output is correct
4 Correct 868 ms 760 KB Output is correct
5 Correct 841 ms 800 KB Output is correct
6 Correct 512 ms 896 KB Output is correct
7 Correct 499 ms 768 KB Output is correct
8 Correct 4 ms 776 KB Output is correct
9 Correct 4 ms 776 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 698 ms 888 KB Output is correct
12 Correct 569 ms 1024 KB Output is correct
13 Correct 579 ms 1008 KB Output is correct
14 Correct 545 ms 768 KB Output is correct
15 Correct 57 ms 768 KB Output is correct
16 Correct 108 ms 896 KB Output is correct
17 Correct 122 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1097 ms 888 KB Output is correct
2 Correct 722 ms 768 KB Output is correct
3 Correct 628 ms 768 KB Output is correct
4 Correct 3 ms 776 KB Output is correct
5 Correct 5 ms 988 KB Output is correct
6 Correct 1 ms 888 KB Output is correct
7 Correct 706 ms 776 KB Output is correct
8 Correct 1180 ms 760 KB Output is correct
9 Correct 1021 ms 764 KB Output is correct
10 Correct 652 ms 768 KB Output is correct
11 Correct 8 ms 892 KB Output is correct
12 Correct 6 ms 768 KB Output is correct
13 Correct 5 ms 640 KB Output is correct
14 Correct 5 ms 896 KB Output is correct
15 Correct 2 ms 756 KB Output is correct
16 Correct 659 ms 896 KB Output is correct
17 Correct 676 ms 888 KB Output is correct
18 Correct 509 ms 760 KB Output is correct
19 Correct 717 ms 824 KB Output is correct
20 Correct 663 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 750 ms 1016 KB Output is correct
2 Correct 629 ms 1008 KB Output is correct
3 Correct 963 ms 880 KB Output is correct
4 Correct 790 ms 760 KB Output is correct
5 Correct 688 ms 760 KB Output is correct
6 Correct 675 ms 1024 KB Output is correct
7 Correct 463 ms 768 KB Output is correct
8 Correct 2 ms 904 KB Output is correct
9 Correct 4 ms 776 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 505 ms 896 KB Output is correct
12 Correct 575 ms 768 KB Output is correct
13 Correct 1051 ms 768 KB Output is correct
14 Correct 790 ms 768 KB Output is correct
15 Correct 830 ms 896 KB Output is correct
16 Correct 529 ms 920 KB Output is correct
17 Correct 797 ms 760 KB Output is correct
18 Correct 561 ms 1020 KB Output is correct
19 Correct 534 ms 1136 KB Output is correct
20 Correct 671 ms 768 KB Output is correct
21 Correct 92 ms 768 KB Output is correct
22 Correct 82 ms 768 KB Output is correct
23 Correct 134 ms 896 KB Output is correct
24 Correct 7 ms 888 KB Output is correct
25 Correct 7 ms 800 KB Output is correct
26 Correct 5 ms 888 KB Output is correct
27 Correct 5 ms 896 KB Output is correct
28 Correct 2 ms 768 KB Output is correct
29 Correct 592 ms 768 KB Output is correct
30 Correct 672 ms 800 KB Output is correct
31 Correct 631 ms 896 KB Output is correct
32 Correct 670 ms 776 KB Output is correct
33 Correct 666 ms 760 KB Output is correct
34 Correct 428 ms 1024 KB Output is correct
35 Correct 605 ms 992 KB Output is correct
36 Correct 571 ms 1032 KB Output is correct
37 Correct 581 ms 1016 KB Output is correct
38 Correct 605 ms 1016 KB Output is correct
39 Correct 563 ms 1096 KB Output is correct
40 Correct 492 ms 1024 KB Output is correct
41 Correct 538 ms 888 KB Output is correct
42 Correct 96 ms 800 KB Output is correct
43 Correct 171 ms 928 KB Output is correct
44 Correct 141 ms 768 KB Output is correct
45 Correct 179 ms 768 KB Output is correct
46 Correct 467 ms 896 KB Output is correct
47 Correct 488 ms 772 KB Output is correct
48 Correct 76 ms 1024 KB Output is correct
49 Correct 83 ms 832 KB Output is correct