답안 #915969

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915969 2024-01-25T04:13:17 Z biank 벽 (IOI14_wall) C++14
100 / 100
725 ms 70012 KB
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<int(n);i++)
const int INF = 1e9;

struct Node {
    int remove, add;
    Node() : remove(INF), add(0) {}
};

const int SZ = 1<<21;
Node st[2*SZ];

void maxi(int &x, int h) { if(h>x) x=h; }
void mini(int &x, int h) { if(h<x) x=h; }

void compute(int u, Node h) {
    mini(st[u].remove,h.remove);
    mini(st[u].add,st[u].remove);
    maxi(st[u].add,h.add);
    maxi(st[u].remove,st[u].add);
}
    
void pass(int u) {
    if(u<SZ) {
        compute(2*u,st[u]);
        compute(2*u+1,st[u]);
        st[u]=Node();
    }
}

void update(int a, int b, Node h, int l=0, int r=SZ, int u=1) {
    pass(u);
    if(b<=l||r<=a) return;
    if(a<=l&&r<=b) return compute(u,h);
    int m=(l+r)/2;
    update(a,b,h,l,m,2*u);
    update(a,b,h,m,r,2*u+1);
}

void dfs(int ans[], int n, int l=0, int r=SZ, int u=1) {
    pass(u);
    if(r-l==1) {
        if(l<n) ans[l]=st[u].add;
        return;
    }
    int m=(l+r)/2;
    dfs(ans,n,l,m,2*u);
    dfs(ans,n,m,r,2*u+1);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
    forn(i,k) {
        Node upd;
        if(op[i]==1) upd.add=height[i];
        else upd.remove=height[i];
        update(left[i],right[i]+1,upd);
    }
    dfs(finalHeight,n);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 33116 KB Output is correct
2 Correct 31 ms 33372 KB Output is correct
3 Correct 30 ms 33116 KB Output is correct
4 Correct 35 ms 33372 KB Output is correct
5 Correct 33 ms 33444 KB Output is correct
6 Correct 34 ms 33372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 33116 KB Output is correct
2 Correct 266 ms 46828 KB Output is correct
3 Correct 238 ms 40276 KB Output is correct
4 Correct 579 ms 51192 KB Output is correct
5 Correct 348 ms 52296 KB Output is correct
6 Correct 328 ms 50652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 33116 KB Output is correct
2 Correct 31 ms 33372 KB Output is correct
3 Correct 31 ms 33116 KB Output is correct
4 Correct 36 ms 33460 KB Output is correct
5 Correct 34 ms 33372 KB Output is correct
6 Correct 34 ms 33372 KB Output is correct
7 Correct 31 ms 33116 KB Output is correct
8 Correct 286 ms 46720 KB Output is correct
9 Correct 234 ms 40276 KB Output is correct
10 Correct 596 ms 51240 KB Output is correct
11 Correct 333 ms 52116 KB Output is correct
12 Correct 325 ms 50892 KB Output is correct
13 Correct 29 ms 33264 KB Output is correct
14 Correct 272 ms 46916 KB Output is correct
15 Correct 66 ms 34388 KB Output is correct
16 Correct 725 ms 51732 KB Output is correct
17 Correct 345 ms 50916 KB Output is correct
18 Correct 338 ms 50772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 33364 KB Output is correct
2 Correct 33 ms 33380 KB Output is correct
3 Correct 31 ms 33112 KB Output is correct
4 Correct 35 ms 33372 KB Output is correct
5 Correct 33 ms 33372 KB Output is correct
6 Correct 33 ms 33452 KB Output is correct
7 Correct 30 ms 33372 KB Output is correct
8 Correct 265 ms 46732 KB Output is correct
9 Correct 234 ms 40268 KB Output is correct
10 Correct 588 ms 51280 KB Output is correct
11 Correct 331 ms 52284 KB Output is correct
12 Correct 321 ms 50620 KB Output is correct
13 Correct 28 ms 33116 KB Output is correct
14 Correct 278 ms 46912 KB Output is correct
15 Correct 67 ms 34388 KB Output is correct
16 Correct 719 ms 51544 KB Output is correct
17 Correct 359 ms 50784 KB Output is correct
18 Correct 345 ms 50804 KB Output is correct
19 Correct 657 ms 70012 KB Output is correct
20 Correct 671 ms 67068 KB Output is correct
21 Correct 655 ms 69684 KB Output is correct
22 Correct 643 ms 67052 KB Output is correct
23 Correct 651 ms 67156 KB Output is correct
24 Correct 643 ms 67156 KB Output is correct
25 Correct 647 ms 67416 KB Output is correct
26 Correct 676 ms 69936 KB Output is correct
27 Correct 658 ms 69472 KB Output is correct
28 Correct 650 ms 67068 KB Output is correct
29 Correct 654 ms 67264 KB Output is correct
30 Correct 670 ms 67012 KB Output is correct