답안 #436485

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
436485 2021-06-24T14:17:37 Z yuto1115 기지국 (IOI20_stations) C++17
100 / 100
1224 ms 692 KB
#include "stations.h"
#include "bits/stdc++.h"
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++)
#define rrep(i, n) for(ll i = ll(n)-1; i >= 0; i--)
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<P>;
using vvp = vector<vp>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

template<class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

vi label(int n, int k, vi u, vi v) {
    vvi G(n);
    rep(i, n - 1) {
        G[u[i]].pb(v[i]);
        G[v[i]].pb(u[i]);
    }
    int idx = 0;
    vi res(n);
    auto dfs = [&](auto &dfs, int now, int p, int d) -> void {
        if (d == 0) res[now] = idx++;
        for (int nx : G[now]) {
            if (nx == p) continue;
            dfs(dfs, nx, now, d ^ 1);
        }
        if (d == 1) res[now] = idx++;
    };
    dfs(dfs, 0, -1, 0);
    assert(idx == n);
    return res;
}

int find_next_station(int s, int t, vi c) {
    if (c[0] < s) {
        int pre = s;
        rrep(i, c.size()) {
            if (c[i] <= t and t < pre) return c[i];
            pre = c[i];
        }
        return pre;
    } else {
        int pre = s;
        rep(i, c.size()) {
            if (pre < t and t <= c[i]) return c[i];
            pre = c[i];
        }
        return pre;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 877 ms 488 KB Output is correct
2 Correct 625 ms 480 KB Output is correct
3 Correct 1138 ms 400 KB Output is correct
4 Correct 803 ms 400 KB Output is correct
5 Correct 661 ms 492 KB Output is correct
6 Correct 643 ms 488 KB Output is correct
7 Correct 624 ms 476 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 6 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 628 ms 488 KB Output is correct
2 Correct 737 ms 476 KB Output is correct
3 Correct 940 ms 464 KB Output is correct
4 Correct 857 ms 492 KB Output is correct
5 Correct 820 ms 488 KB Output is correct
6 Correct 542 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 715 ms 484 KB Output is correct
2 Correct 569 ms 580 KB Output is correct
3 Correct 1117 ms 488 KB Output is correct
4 Correct 797 ms 400 KB Output is correct
5 Correct 818 ms 476 KB Output is correct
6 Correct 492 ms 480 KB Output is correct
7 Correct 587 ms 488 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 6 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 832 ms 488 KB Output is correct
12 Correct 748 ms 652 KB Output is correct
13 Correct 434 ms 692 KB Output is correct
14 Correct 583 ms 488 KB Output is correct
15 Correct 85 ms 448 KB Output is correct
16 Correct 102 ms 528 KB Output is correct
17 Correct 160 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1224 ms 400 KB Output is correct
2 Correct 795 ms 400 KB Output is correct
3 Correct 765 ms 520 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 6 ms 468 KB Output is correct
6 Correct 2 ms 448 KB Output is correct
7 Correct 769 ms 400 KB Output is correct
8 Correct 1182 ms 400 KB Output is correct
9 Correct 813 ms 472 KB Output is correct
10 Correct 756 ms 488 KB Output is correct
11 Correct 6 ms 468 KB Output is correct
12 Correct 8 ms 464 KB Output is correct
13 Correct 6 ms 468 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 2 ms 480 KB Output is correct
16 Correct 551 ms 400 KB Output is correct
17 Correct 595 ms 484 KB Output is correct
18 Correct 607 ms 492 KB Output is correct
19 Correct 639 ms 528 KB Output is correct
20 Correct 709 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 546 ms 476 KB Output is correct
2 Correct 619 ms 576 KB Output is correct
3 Correct 991 ms 400 KB Output is correct
4 Correct 955 ms 488 KB Output is correct
5 Correct 780 ms 612 KB Output is correct
6 Correct 639 ms 528 KB Output is correct
7 Correct 507 ms 528 KB Output is correct
8 Correct 4 ms 468 KB Output is correct
9 Correct 6 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 552 ms 528 KB Output is correct
12 Correct 591 ms 528 KB Output is correct
13 Correct 1176 ms 488 KB Output is correct
14 Correct 841 ms 400 KB Output is correct
15 Correct 768 ms 484 KB Output is correct
16 Correct 579 ms 492 KB Output is correct
17 Correct 774 ms 484 KB Output is correct
18 Correct 594 ms 596 KB Output is correct
19 Correct 589 ms 564 KB Output is correct
20 Correct 532 ms 528 KB Output is correct
21 Correct 64 ms 444 KB Output is correct
22 Correct 98 ms 600 KB Output is correct
23 Correct 101 ms 528 KB Output is correct
24 Correct 7 ms 480 KB Output is correct
25 Correct 7 ms 480 KB Output is correct
26 Correct 5 ms 468 KB Output is correct
27 Correct 5 ms 476 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 561 ms 400 KB Output is correct
30 Correct 603 ms 400 KB Output is correct
31 Correct 730 ms 400 KB Output is correct
32 Correct 649 ms 484 KB Output is correct
33 Correct 645 ms 484 KB Output is correct
34 Correct 450 ms 572 KB Output is correct
35 Correct 426 ms 572 KB Output is correct
36 Correct 629 ms 488 KB Output is correct
37 Correct 558 ms 608 KB Output is correct
38 Correct 562 ms 556 KB Output is correct
39 Correct 463 ms 572 KB Output is correct
40 Correct 470 ms 668 KB Output is correct
41 Correct 723 ms 552 KB Output is correct
42 Correct 70 ms 548 KB Output is correct
43 Correct 140 ms 528 KB Output is correct
44 Correct 181 ms 528 KB Output is correct
45 Correct 148 ms 528 KB Output is correct
46 Correct 420 ms 528 KB Output is correct
47 Correct 413 ms 484 KB Output is correct
48 Correct 67 ms 632 KB Output is correct
49 Correct 84 ms 528 KB Output is correct