답안 #931079

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
931079 2024-02-21T07:56:59 Z Art_ogo 벽 (IOI14_wall) C++17
61 / 100
380 ms 107236 KB
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <algorithm>
#include <utility>
#include "wall.h"
using namespace std;

const int MAXN = 1e6+10;

int t[4*MAXN];
int modmn[4*MAXN], modmx[4*MAXN];

void build(int v, int tl, int tr){
    modmn[v] = 1e9;
    modmx[v] = -1e9;
    if(tl == tr){
        t[v] = 0;
        return;
    }
    int tm = (tl + tr) >> 1;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
}

void push(int v){
    if(v * 2 + 1 > 4*MAXN) return;
    if(modmn[v] != 1e9){
        t[v * 2] = min(t[v * 2], modmn[v]);
        modmn[v * 2] = min(modmn[v], modmn[v * 2]);
        modmx[v * 2] = min(modmn[v], modmx[v * 2]);
        t[v * 2 + 1] = min(t[v * 2 + 1], modmn[v]);
        modmn[v * 2 + 1] = min(modmn[v], modmn[v * 2 + 1]);
        modmx[v * 2 + 1] = min(modmn[v], modmx[v * 2 + 1]);
        modmn[v] = 1e9;
    }
    if(modmx[v] != -1e9){
        t[v * 2] = max(t[v * 2], modmx[v]);
        modmn[v * 2] = max(modmx[v], modmn[v * 2]);
        modmx[v * 2] = max(modmx[v], modmx[v * 2]);
        t[v * 2 + 1] = max(t[v * 2 + 1], modmx[v]);
        modmn[v * 2 + 1] = max(modmx[v], modmn[v * 2 + 1]);
        modmx[v * 2 + 1] = max(modmx[v], modmx[v * 2 + 1]);
        modmx[v] = -1e9;
    }
}

void updmx(int l, int r, int val, int v, int tl, int tr){
    if(tl >= l && tr <= r){
        t[v] = max(t[v], val);
        modmn[v] = max(modmn[v], val);
        modmx[v] = max(modmx[v], val);
        return;
    }
    if(tl > r || tr < l)
        return;
    push(v);
    int tm = (tl + tr) >> 1;
    updmx(l, r, val, v * 2, tl, tm);
    updmx(l, r, val, v * 2 + 1, tm + 1, tr);
}

void updmn(int l, int r, int val, int v, int tl, int tr){
    if(tl >= l && tr <= r){
        t[v] = min(t[v], val);
        modmn[v] = min(modmn[v], val);
        modmx[v] = min(modmx[v], val);
        return;
    }
    if(tl > r || tr < l)
        return;
    push(v);
    int tm = (tl + tr) >> 1;
    updmn(l, r, val, v * 2, tl, tm);
    updmn(l, r, val, v * 2 + 1, tm + 1, tr);
}

int get(int idx, int v, int tl, int tr){
    if(tl == tr)
        return t[v];
    push(v);
    int tm = (tl + tr) >> 1;
    if(idx <= tm)
        return get(idx, v * 2, tl, tm);
    else return get(idx, v * 2 + 1, tm + 1, tr);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    build(1, 0, n - 1);
    for(int i = 0; i < k; i++)
        if(op[i] == 1)
            updmx(left[i], right[i], height[i], 1, 0, n - 1);
        else updmn(left[i], right[i], height[i], 1, 0, n - 1);
    for(int i = 0; i < n; i++)
        finalHeight[i] = get(i, 1, 0, n - 1);
    return;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 5 ms 4640 KB Output is correct
5 Correct 4 ms 4700 KB Output is correct
6 Correct 4 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 99 ms 12316 KB Output is correct
3 Correct 115 ms 8092 KB Output is correct
4 Correct 323 ms 15944 KB Output is correct
5 Correct 198 ms 16468 KB Output is correct
6 Correct 191 ms 16468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 3 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 5 ms 4776 KB Output is correct
5 Correct 4 ms 4700 KB Output is correct
6 Correct 4 ms 4700 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 98 ms 12232 KB Output is correct
9 Correct 112 ms 8100 KB Output is correct
10 Correct 324 ms 15948 KB Output is correct
11 Correct 194 ms 16468 KB Output is correct
12 Correct 190 ms 16392 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 110 ms 12436 KB Output is correct
15 Correct 22 ms 5208 KB Output is correct
16 Correct 370 ms 16276 KB Output is correct
17 Correct 193 ms 16128 KB Output is correct
18 Correct 194 ms 16208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 5 ms 4700 KB Output is correct
5 Correct 4 ms 4700 KB Output is correct
6 Correct 4 ms 4700 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 99 ms 12220 KB Output is correct
9 Correct 120 ms 8100 KB Output is correct
10 Correct 311 ms 15944 KB Output is correct
11 Correct 195 ms 16468 KB Output is correct
12 Correct 188 ms 16364 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 100 ms 12208 KB Output is correct
15 Correct 22 ms 5208 KB Output is correct
16 Correct 380 ms 16208 KB Output is correct
17 Correct 191 ms 16252 KB Output is correct
18 Correct 193 ms 16076 KB Output is correct
19 Runtime error 174 ms 107236 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -