답안 #385366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
385366 2021-04-04T06:10:36 Z ParsaAlizadeh 벽 (IOI14_wall) C++17
100 / 100
821 ms 59512 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;

#define lc  (id << 1)
#define rc  (lc | 1)

typedef long long ll;
int const N = 2e6 + 5;

int seg[N << 2][2];

inline void apply(int mn, int mx, int res[2]) {
    for (int i : {0, 1})
        res[i] = min(mx, max(mn, res[i]));
}

inline void shift(int id) {
    apply(seg[id][0], seg[id][1], seg[lc]);
    apply(seg[id][0], seg[id][1], seg[rc]);
    seg[id][0] = 0;
    seg[id][1] = INT_MAX;
}

void build(int id, int l, int r) {
    if (r - l == 1) {
        return;
    }
    int mid = (l + r) >> 1;
    build(lc, l, mid); build(rc, mid, r);
    seg[id][1] = INT_MAX;
}

void update(int id, int l, int r, int ql, int qr, int mn, int mx) {
    if (qr <= l || r <= ql)
        return;
    if (ql <= l && r <= qr)
        return apply(mn, mx, seg[id]);
    shift(id);
    int mid = (l + r) >> 1;
    update(lc, l, mid, ql, qr, mn, mx);
    update(rc, mid, r, ql, qr, mn, mx);
}

void finish(int id, int l, int r, int arr[]) {
    if (r - l == 1) {
        arr[l] = seg[id][0];
        return;
    }
    shift(id);
    int mid = (l + r) >> 1;
    finish(lc, l, mid, arr);
    finish(rc, mid, r, arr);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    build(1, 0, n);
    for (int i = 0; i < k; i++) {
        if (op[i] == 1) {
            update(1, 0, n, left[i], right[i] + 1, height[i], INT_MAX);
        }
        else {
            update(1, 0, n, left[i], right[i] + 1, 0, height[i]);
        }
    }
    finish(1, 0, n, finalHeight);
    return;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 3 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 7 ms 748 KB Output is correct
5 Correct 6 ms 748 KB Output is correct
6 Correct 8 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 167 ms 8172 KB Output is correct
3 Correct 182 ms 4332 KB Output is correct
4 Correct 505 ms 10908 KB Output is correct
5 Correct 348 ms 11372 KB Output is correct
6 Correct 333 ms 11296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 3 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 7 ms 748 KB Output is correct
5 Correct 6 ms 748 KB Output is correct
6 Correct 7 ms 748 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 165 ms 8172 KB Output is correct
9 Correct 184 ms 4252 KB Output is correct
10 Correct 555 ms 10780 KB Output is correct
11 Correct 336 ms 11292 KB Output is correct
12 Correct 347 ms 11340 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 187 ms 8172 KB Output is correct
15 Correct 29 ms 1516 KB Output is correct
16 Correct 564 ms 11040 KB Output is correct
17 Correct 340 ms 11116 KB Output is correct
18 Correct 325 ms 11116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 3 ms 364 KB Output is correct
3 Correct 3 ms 364 KB Output is correct
4 Correct 6 ms 748 KB Output is correct
5 Correct 6 ms 748 KB Output is correct
6 Correct 6 ms 748 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 172 ms 8300 KB Output is correct
9 Correct 181 ms 4204 KB Output is correct
10 Correct 493 ms 10860 KB Output is correct
11 Correct 330 ms 11372 KB Output is correct
12 Correct 323 ms 11500 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 164 ms 8172 KB Output is correct
15 Correct 29 ms 1516 KB Output is correct
16 Correct 502 ms 11244 KB Output is correct
17 Correct 337 ms 11116 KB Output is correct
18 Correct 326 ms 11292 KB Output is correct
19 Correct 804 ms 59244 KB Output is correct
20 Correct 796 ms 56940 KB Output is correct
21 Correct 821 ms 59500 KB Output is correct
22 Correct 811 ms 56892 KB Output is correct
23 Correct 808 ms 56812 KB Output is correct
24 Correct 799 ms 56960 KB Output is correct
25 Correct 797 ms 56716 KB Output is correct
26 Correct 799 ms 59500 KB Output is correct
27 Correct 808 ms 59512 KB Output is correct
28 Correct 790 ms 56844 KB Output is correct
29 Correct 795 ms 56940 KB Output is correct
30 Correct 789 ms 56940 KB Output is correct