답안 #836068

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
836068 2023-08-24T06:54:28 Z maomao90 기지국 (IOI20_stations) C++17
100 / 100
753 ms 760 KB
// I can do all things through Christ who strengthens me
// Philippians 4:13

#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

#define REP(i, j, k) for (int i = j; i < (k); i++)
#define RREP(i, j, k) for (int i = j; i >= (k); i--)

template <class T>
inline bool mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005;
const int MAXN = 500005;

vi label(int n, int k, vi u, vi v) {
    vector<vi> adj(n);
    REP (i, 0, n - 1) {
        adj[u[i]].pb(v[i]);
        adj[v[i]].pb(u[i]);
    }
    int ptr = 0;
    vi l(n);
    vi d(n);
    function<void(int, int)> dfs = [&] (int u, int p) {
        if (d[u] == 0) {
            l[u] = ptr++;
        }
        for (int v : adj[u]) {
            if (v == p) {
                continue;
            }
            d[v] = d[u] ^ 1;
            dfs(v, u);
        }
        if (d[u] == 1) {
            l[u] = ptr++;
        }
    };
    dfs(0, -1);
    return l;
}

int find_next_station(int s, int t, vi c) {
    if (SZ(c) == 1) {
        return c[0];
    }
    if (s > c.back()) {
        if (t < c[1] || t > s) {
            return c[0];
        }
        RREP (i, SZ(c) - 1, 1) {
            if (c[i] <= t) {
                return c[i];
            }
        }
        assert(0);
    } else {
        assert(s < c[0]);
        if (s != 0 && (t < s || t > c[SZ(c) - 2])) {
            return c.back();
        }
        REP (i, 0, SZ(c) - (s > 0)) {
            if (t <= c[i]) {
                return c[i];
            }
        }
        assert(0);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 371 ms 632 KB Output is correct
2 Correct 341 ms 672 KB Output is correct
3 Correct 551 ms 512 KB Output is correct
4 Correct 407 ms 416 KB Output is correct
5 Correct 350 ms 504 KB Output is correct
6 Correct 299 ms 636 KB Output is correct
7 Correct 306 ms 700 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 2 ms 488 KB Output is correct
10 Correct 0 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 288 ms 632 KB Output is correct
2 Correct 327 ms 644 KB Output is correct
3 Correct 522 ms 508 KB Output is correct
4 Correct 454 ms 504 KB Output is correct
5 Correct 349 ms 416 KB Output is correct
6 Correct 303 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 359 ms 736 KB Output is correct
2 Correct 305 ms 636 KB Output is correct
3 Correct 594 ms 504 KB Output is correct
4 Correct 422 ms 416 KB Output is correct
5 Correct 367 ms 420 KB Output is correct
6 Correct 269 ms 676 KB Output is correct
7 Correct 278 ms 556 KB Output is correct
8 Correct 1 ms 496 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 0 ms 500 KB Output is correct
11 Correct 405 ms 508 KB Output is correct
12 Correct 438 ms 676 KB Output is correct
13 Correct 398 ms 712 KB Output is correct
14 Correct 416 ms 548 KB Output is correct
15 Correct 35 ms 504 KB Output is correct
16 Correct 59 ms 572 KB Output is correct
17 Correct 63 ms 568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 573 ms 416 KB Output is correct
2 Correct 475 ms 504 KB Output is correct
3 Correct 402 ms 416 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 4 ms 548 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 476 ms 500 KB Output is correct
8 Correct 753 ms 504 KB Output is correct
9 Correct 569 ms 508 KB Output is correct
10 Correct 405 ms 512 KB Output is correct
11 Correct 4 ms 504 KB Output is correct
12 Correct 3 ms 500 KB Output is correct
13 Correct 3 ms 492 KB Output is correct
14 Correct 2 ms 500 KB Output is correct
15 Correct 1 ms 496 KB Output is correct
16 Correct 424 ms 504 KB Output is correct
17 Correct 402 ms 416 KB Output is correct
18 Correct 482 ms 420 KB Output is correct
19 Correct 377 ms 420 KB Output is correct
20 Correct 335 ms 424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 473 ms 700 KB Output is correct
2 Correct 338 ms 668 KB Output is correct
3 Correct 607 ms 504 KB Output is correct
4 Correct 618 ms 420 KB Output is correct
5 Correct 550 ms 416 KB Output is correct
6 Correct 251 ms 680 KB Output is correct
7 Correct 425 ms 548 KB Output is correct
8 Correct 1 ms 488 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
11 Correct 405 ms 544 KB Output is correct
12 Correct 404 ms 576 KB Output is correct
13 Correct 572 ms 504 KB Output is correct
14 Correct 481 ms 420 KB Output is correct
15 Correct 394 ms 504 KB Output is correct
16 Correct 290 ms 612 KB Output is correct
17 Correct 386 ms 416 KB Output is correct
18 Correct 383 ms 760 KB Output is correct
19 Correct 401 ms 712 KB Output is correct
20 Correct 352 ms 548 KB Output is correct
21 Correct 47 ms 420 KB Output is correct
22 Correct 52 ms 572 KB Output is correct
23 Correct 68 ms 544 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 4 ms 492 KB Output is correct
26 Correct 1 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 434 ms 416 KB Output is correct
30 Correct 521 ms 416 KB Output is correct
31 Correct 278 ms 504 KB Output is correct
32 Correct 514 ms 568 KB Output is correct
33 Correct 485 ms 572 KB Output is correct
34 Correct 235 ms 692 KB Output is correct
35 Correct 384 ms 632 KB Output is correct
36 Correct 414 ms 736 KB Output is correct
37 Correct 279 ms 728 KB Output is correct
38 Correct 338 ms 628 KB Output is correct
39 Correct 344 ms 584 KB Output is correct
40 Correct 358 ms 628 KB Output is correct
41 Correct 366 ms 632 KB Output is correct
42 Correct 46 ms 548 KB Output is correct
43 Correct 69 ms 544 KB Output is correct
44 Correct 114 ms 544 KB Output is correct
45 Correct 145 ms 544 KB Output is correct
46 Correct 305 ms 544 KB Output is correct
47 Correct 290 ms 632 KB Output is correct
48 Correct 43 ms 720 KB Output is correct
49 Correct 48 ms 636 KB Output is correct