답안 #17238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
17238 2015-11-09T13:38:07 Z murat 벽 (IOI14_wall) C++
100 / 100
881 ms 118924 KB
#include "wall.h"
#include<bits/stdc++.h>

#define sol (k + k)
#define sag (k + k + 1)

using namespace std;

const int N = 2e6 + 5;
const int inf = 1e9 + 7;

class node {
    public:
    int min, max, t;
    node() { min = inf; max = -inf; t = -1; }
} ST[N << 2];

int n, m, x, y, z, ans[N];

void upd_max(node &x, int t) {
    x.t = 0;
    x.max = max(x.max, t);
    x.min = max(x.min, t);
}
void upd_min(node &x, int t) {
    x.t = 1;
    x.max = min(x.max, t);
    x.min = min(x.min, t);
}

void push(int k) {
    if(ST[k].t == -1) return ;
    if(ST[k].t) {
        upd_max(ST[sol], ST[k].max);
        upd_min(ST[sol], ST[k].min);
        upd_max(ST[sag], ST[k].max);
        upd_min(ST[sag], ST[k].min);
    }
    else {
        upd_min(ST[sol], ST[k].min);
        upd_max(ST[sol], ST[k].max);
        upd_min(ST[sag], ST[k].min);
        upd_max(ST[sag], ST[k].max);
    }
    ST[k].t = -1;
    ST[k].min = inf;
    ST[k].max = -inf;
}

void push_max(int k, int bas, int son, int x, int y, int t) {
    if(bas > y || son < x) return ;
    if(x <= bas && son <= y) {
        upd_max(ST[k], t);
        return ;
    }
    push(k);
    push_max(k + k, bas, (bas+son)/2, x, y, t);
    push_max(k + k + 1, (bas+son)/2+1, son, x, y, t);
}

void push_min(int k, int bas, int son, int x, int y, int t) {
    if(bas > y || son < x) return ;
    if(x <= bas && son <= y) {
        upd_min(ST[k], t);
        return ;
    }
    push(k);
    push_min(k + k, bas, (bas+son)/2, x, y, t);
    push_min(k + k + 1, (bas+son)/2+1, son, x, y, t);
}

void solve(int k, int bas, int son) {
    if(bas == son) {
        if(ST[k].t == -1) return ;
        if(ST[k].t == 0) {
            ans[bas] = min(ans[bas], ST[k].min);
            ans[bas] = max(ans[bas], ST[k].max);
        }
        else {
            ans[bas] = min(ans[bas], ST[k].min);
            ans[bas] = max(ans[bas], ST[k].max);
        }
        return ;
    }
    push(k);
    solve(sol, bas, (bas + son)/2);
    solve(sag, (bas + son)/2+1, son);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){

    ::n = n;

    for(int i = 0; i < k; i++) {
        if(op[i] == 1) push_max(1, 1, n, left[i]+1, right[i]+1, height[i]);
        else push_min(1, 1, n, left[i]+1, right[i]+1, height[i]);
        //for(int j = left[i]+1; j <= right[i]+1; j++)
        //if(op[i] == 1) push_max(1, 1, n, j, j, height[i]);
        //else push_min(1, 1, n, j, j, height[i]);
    }

    solve(1, 1, n);

    for(int i = 1; i <= n; i++)
        finalHeight[i-1] = ans[i];

    return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 103284 KB Output is correct
2 Correct 8 ms 103284 KB Output is correct
3 Correct 17 ms 103284 KB Output is correct
4 Correct 24 ms 103284 KB Output is correct
5 Correct 8 ms 103284 KB Output is correct
6 Correct 4 ms 103284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 103284 KB Output is correct
2 Correct 187 ms 111108 KB Output is correct
3 Correct 272 ms 106532 KB Output is correct
4 Correct 707 ms 111500 KB Output is correct
5 Correct 350 ms 111500 KB Output is correct
6 Correct 324 ms 111500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 103284 KB Output is correct
2 Correct 14 ms 103284 KB Output is correct
3 Correct 8 ms 103284 KB Output is correct
4 Correct 22 ms 103284 KB Output is correct
5 Correct 9 ms 103284 KB Output is correct
6 Correct 16 ms 103284 KB Output is correct
7 Correct 22 ms 103284 KB Output is correct
8 Correct 195 ms 111108 KB Output is correct
9 Correct 294 ms 106532 KB Output is correct
10 Correct 667 ms 111500 KB Output is correct
11 Correct 376 ms 111500 KB Output is correct
12 Correct 352 ms 111500 KB Output is correct
13 Correct 23 ms 103284 KB Output is correct
14 Correct 207 ms 111108 KB Output is correct
15 Correct 55 ms 103768 KB Output is correct
16 Correct 862 ms 111500 KB Output is correct
17 Correct 357 ms 111500 KB Output is correct
18 Correct 358 ms 111500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 103284 KB Output is correct
2 Correct 16 ms 103284 KB Output is correct
3 Correct 9 ms 103284 KB Output is correct
4 Correct 24 ms 103284 KB Output is correct
5 Correct 23 ms 103284 KB Output is correct
6 Correct 14 ms 103284 KB Output is correct
7 Correct 13 ms 103284 KB Output is correct
8 Correct 198 ms 111108 KB Output is correct
9 Correct 287 ms 106532 KB Output is correct
10 Correct 722 ms 111500 KB Output is correct
11 Correct 374 ms 111500 KB Output is correct
12 Correct 346 ms 111500 KB Output is correct
13 Correct 19 ms 103284 KB Output is correct
14 Correct 184 ms 111108 KB Output is correct
15 Correct 54 ms 103768 KB Output is correct
16 Correct 881 ms 111500 KB Output is correct
17 Correct 387 ms 111500 KB Output is correct
18 Correct 361 ms 111500 KB Output is correct
19 Correct 784 ms 118924 KB Output is correct
20 Correct 837 ms 118924 KB Output is correct
21 Correct 793 ms 118924 KB Output is correct
22 Correct 764 ms 118924 KB Output is correct
23 Correct 828 ms 118924 KB Output is correct
24 Correct 808 ms 118924 KB Output is correct
25 Correct 761 ms 118924 KB Output is correct
26 Correct 871 ms 118924 KB Output is correct
27 Correct 850 ms 118924 KB Output is correct
28 Correct 787 ms 118924 KB Output is correct
29 Correct 792 ms 118924 KB Output is correct
30 Correct 790 ms 118924 KB Output is correct