Submission #429254

# Submission time Handle Problem Language Result Execution time Memory
429254 2021-06-15T19:34:53 Z MarcoMeijer Stations (IOI20_stations) C++14
100 / 100
1216 ms 908 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

vi label(int n, int k, vi u, vi v) {
    vector<vi> adj(n,vi(0));

    RE(i,n-1) adj[u[i]].pb(v[i]), adj[v[i]].pb(u[i]);

	vi labels(n);
    int nextLabel = 0;

    function<void(int,int,int)> dfs = [&](int u, int p, int cur) {
        if(cur) labels[u] = nextLabel++;
        FOR(v,adj[u]) {
            if(v == p) continue;
            dfs(v,u,!cur);
        }
        if(!cur) labels[u] = nextLabel++;
    };
    
    dfs(0,0,0);

	return labels;
}

int find_next_station(int s, int t, vi c) {
    if(c[0] > s) {
        if(t < s || t >= c.back())
            return c.back();
        auto it = lower_bound(all(c),t);
        return *it;
    } else {
        if(t <= c[0] || t > s)
            return c[0];
        auto it = upper_bound(all(c),t);
        --it;
        return *it;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 632 ms 608 KB Output is correct
2 Correct 567 ms 664 KB Output is correct
3 Correct 1134 ms 400 KB Output is correct
4 Correct 804 ms 488 KB Output is correct
5 Correct 714 ms 472 KB Output is correct
6 Correct 666 ms 636 KB Output is correct
7 Correct 716 ms 596 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 2 ms 420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 594 ms 488 KB Output is correct
2 Correct 472 ms 528 KB Output is correct
3 Correct 1013 ms 400 KB Output is correct
4 Correct 844 ms 528 KB Output is correct
5 Correct 708 ms 472 KB Output is correct
6 Correct 474 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 729 ms 616 KB Output is correct
2 Correct 565 ms 656 KB Output is correct
3 Correct 1216 ms 400 KB Output is correct
4 Correct 764 ms 492 KB Output is correct
5 Correct 910 ms 400 KB Output is correct
6 Correct 640 ms 620 KB Output is correct
7 Correct 513 ms 528 KB Output is correct
8 Correct 3 ms 476 KB Output is correct
9 Correct 7 ms 468 KB Output is correct
10 Correct 2 ms 476 KB Output is correct
11 Correct 676 ms 616 KB Output is correct
12 Correct 541 ms 684 KB Output is correct
13 Correct 607 ms 908 KB Output is correct
14 Correct 424 ms 532 KB Output is correct
15 Correct 70 ms 420 KB Output is correct
16 Correct 90 ms 544 KB Output is correct
17 Correct 135 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1045 ms 400 KB Output is correct
2 Correct 810 ms 484 KB Output is correct
3 Correct 631 ms 400 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 2 ms 480 KB Output is correct
7 Correct 709 ms 468 KB Output is correct
8 Correct 1073 ms 464 KB Output is correct
9 Correct 704 ms 400 KB Output is correct
10 Correct 773 ms 400 KB Output is correct
11 Correct 8 ms 468 KB Output is correct
12 Correct 8 ms 472 KB Output is correct
13 Correct 5 ms 476 KB Output is correct
14 Correct 4 ms 468 KB Output is correct
15 Correct 2 ms 476 KB Output is correct
16 Correct 530 ms 488 KB Output is correct
17 Correct 605 ms 400 KB Output is correct
18 Correct 629 ms 400 KB Output is correct
19 Correct 641 ms 484 KB Output is correct
20 Correct 470 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 603 ms 800 KB Output is correct
2 Correct 593 ms 520 KB Output is correct
3 Correct 837 ms 484 KB Output is correct
4 Correct 790 ms 492 KB Output is correct
5 Correct 594 ms 488 KB Output is correct
6 Correct 469 ms 596 KB Output is correct
7 Correct 528 ms 616 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 1 ms 400 KB Output is correct
11 Correct 511 ms 484 KB Output is correct
12 Correct 638 ms 528 KB Output is correct
13 Correct 1152 ms 412 KB Output is correct
14 Correct 880 ms 484 KB Output is correct
15 Correct 594 ms 400 KB Output is correct
16 Correct 582 ms 528 KB Output is correct
17 Correct 859 ms 400 KB Output is correct
18 Correct 519 ms 640 KB Output is correct
19 Correct 548 ms 892 KB Output is correct
20 Correct 511 ms 528 KB Output is correct
21 Correct 50 ms 468 KB Output is correct
22 Correct 102 ms 528 KB Output is correct
23 Correct 107 ms 528 KB Output is correct
24 Correct 6 ms 476 KB Output is correct
25 Correct 7 ms 476 KB Output is correct
26 Correct 6 ms 468 KB Output is correct
27 Correct 5 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 574 ms 540 KB Output is correct
30 Correct 574 ms 620 KB Output is correct
31 Correct 637 ms 400 KB Output is correct
32 Correct 597 ms 528 KB Output is correct
33 Correct 688 ms 492 KB Output is correct
34 Correct 287 ms 656 KB Output is correct
35 Correct 468 ms 656 KB Output is correct
36 Correct 523 ms 612 KB Output is correct
37 Correct 620 ms 648 KB Output is correct
38 Correct 635 ms 560 KB Output is correct
39 Correct 437 ms 724 KB Output is correct
40 Correct 495 ms 572 KB Output is correct
41 Correct 512 ms 560 KB Output is correct
42 Correct 76 ms 528 KB Output is correct
43 Correct 101 ms 548 KB Output is correct
44 Correct 185 ms 568 KB Output is correct
45 Correct 183 ms 528 KB Output is correct
46 Correct 439 ms 556 KB Output is correct
47 Correct 414 ms 620 KB Output is correct
48 Correct 72 ms 528 KB Output is correct
49 Correct 56 ms 656 KB Output is correct