답안 #498619

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498619 2021-12-25T19:59:09 Z gozonite 벽 (IOI14_wall) C++14
100 / 100
582 ms 67756 KB
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <deque>
#include <queue>
#include <tuple>
#include <cmath>
#include <cctype>
#include <stack>
#include <cassert>
using namespace std;
using ll = long long;

int ns;
int lzMin[8000001], lzMax[8000001];
int ans[2000000];

void pushdown(int k, int l, int r) {
    if (l == r) return;
    if (lzMin[k] == -1 && lzMax[k] == 1e6) return;
    for (int j = 2*k; j <= 2*k+1; j++) {
        lzMin[j] = max(lzMin[j], lzMin[k]); lzMax[j] = max(lzMax[j], lzMin[k]);
        lzMax[j] = min(lzMax[j], lzMax[k]); lzMin[j] = min(lzMin[j], lzMax[k]);
    }
    lzMin[k] = -1; lzMax[k] = 1e6;
}
void minr(int a, int b, int v, int k = 1, int l = 0, int r = ns-1) {
    if (r < a || b < l) return;
    if (a <= l && r <= b) {
        lzMin[k] = max(lzMin[k], v);
        lzMax[k] = max(lzMax[k], v);
    } else {
        int mid = (l+r)/2;
        pushdown(k, l, r);
        minr(a, b, v, 2*k, l, mid);
        minr(a, b, v, 2*k+1, mid+1, r);
    }
}
void maxr(int a, int b, int v, int k = 1, int l = 0, int r = ns-1) {
    if (r < a || b < l) return;
    if (a <= l && r <= b) {
        lzMax[k] = min(lzMax[k], v);
        lzMin[k] = min(lzMin[k], v);
    } else {
        int mid = (l+r)/2;
        pushdown(k, l, r);
        maxr(a, b, v, 2*k, l, mid);
        maxr(a, b, v, 2*k+1, mid+1, r);
    }
}
void walk(int k = 1, int l = 0, int r = ns-1) {
    if (l == r) ans[l] = lzMin[k];
    else {
        int mid = (l+r)/2;
        pushdown(k, l, r);
        walk(2*k, l, mid);
        walk(2*k+1, mid+1, r);
    }
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
    ns = n;
    minr(0, n-1, 0); maxr(0, n-1, 0);
    for (int i = 0; i < k; i++) {
        if (op[i] == 1) {
            minr(left[i], right[i], height[i]);
        } else {
            maxr(left[i], right[i], height[i]);
        }
    }

    walk();
    for (int i = 0; i < n; i++) finalHeight[i] = ans[i];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 5 ms 716 KB Output is correct
5 Correct 4 ms 716 KB Output is correct
6 Correct 4 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 150 ms 8612 KB Output is correct
3 Correct 167 ms 4540 KB Output is correct
4 Correct 402 ms 11836 KB Output is correct
5 Correct 247 ms 12440 KB Output is correct
6 Correct 230 ms 12248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 5 ms 716 KB Output is correct
5 Correct 5 ms 844 KB Output is correct
6 Correct 4 ms 676 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 153 ms 8504 KB Output is correct
9 Correct 146 ms 4536 KB Output is correct
10 Correct 388 ms 11792 KB Output is correct
11 Correct 244 ms 12448 KB Output is correct
12 Correct 230 ms 12328 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 148 ms 8524 KB Output is correct
15 Correct 22 ms 1524 KB Output is correct
16 Correct 399 ms 12128 KB Output is correct
17 Correct 244 ms 12096 KB Output is correct
18 Correct 249 ms 11964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 5 ms 672 KB Output is correct
5 Correct 4 ms 716 KB Output is correct
6 Correct 4 ms 716 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 156 ms 8548 KB Output is correct
9 Correct 147 ms 4536 KB Output is correct
10 Correct 399 ms 11856 KB Output is correct
11 Correct 243 ms 12436 KB Output is correct
12 Correct 237 ms 12284 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 150 ms 8536 KB Output is correct
15 Correct 24 ms 1536 KB Output is correct
16 Correct 410 ms 12024 KB Output is correct
17 Correct 241 ms 12052 KB Output is correct
18 Correct 246 ms 12088 KB Output is correct
19 Correct 555 ms 67756 KB Output is correct
20 Correct 554 ms 65312 KB Output is correct
21 Correct 543 ms 67656 KB Output is correct
22 Correct 546 ms 65120 KB Output is correct
23 Correct 544 ms 65140 KB Output is correct
24 Correct 545 ms 65160 KB Output is correct
25 Correct 547 ms 65056 KB Output is correct
26 Correct 536 ms 67572 KB Output is correct
27 Correct 570 ms 67628 KB Output is correct
28 Correct 555 ms 65092 KB Output is correct
29 Correct 582 ms 65248 KB Output is correct
30 Correct 563 ms 65152 KB Output is correct