답안 #1097053

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097053 2024-10-05T23:22:27 Z vjudge1 벽 (IOI14_wall) C++17
100 / 100
605 ms 69476 KB
#include<bits/stdc++.h>
using namespace std;
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for(int i=int(n)-1;i>=int(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define sz(x) int(x.size())
#define all(x) begin(x),end(x)
#define pb push_back
#define fst first
#define snd second

const int INF=1e9;

typedef pair<int,int> ii;

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

template<typename T> void chmax(T &x, T v){ if(v>x) x=v; }
template<typename T> void chmin(T &x, T v){ if(v<x) x=v; }

ii &operator+=(ii &a, ii b){
    chmin(a.fst,b.fst);
    chmin(a.snd,a.fst);
    chmax(a.snd,b.snd);
    chmax(a.fst,a.snd);
    return a;
}
    
void pass(int u) {
    if(u<SZ){
        st[2*u]+=st[u],st[2*u+1]+=st[u];
        st[u]={INF,0};
    }
}

void update(int s, int e, ii v, int l=0, int r=SZ, int u=1){
    pass(u);
    if(e<=l||r<=s) return;
    if(s<=l&&r<=e){
        st[u]+=v;
        return;
    }
    int m=(l+r)/2;
    update(s,e,v,l,m,2*u);
    update(s,e,v,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].snd;
        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(u,2*SZ) st[u]={INF,0};
    forn(i,k){
        ii upd={INF,0};
        if(op[i]==1) upd.snd=height[i];
        else upd.fst=height[i];
        update(left[i],right[i]+1,upd);
    }
    dfs(finalHeight,n);
}

# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 33112 KB Output is correct
2 Correct 33 ms 33368 KB Output is correct
3 Correct 33 ms 33112 KB Output is correct
4 Correct 35 ms 33368 KB Output is correct
5 Correct 33 ms 33368 KB Output is correct
6 Correct 41 ms 33368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 33116 KB Output is correct
2 Correct 249 ms 46876 KB Output is correct
3 Correct 204 ms 40276 KB Output is correct
4 Correct 527 ms 51280 KB Output is correct
5 Correct 269 ms 52308 KB Output is correct
6 Correct 287 ms 50620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 33116 KB Output is correct
2 Correct 34 ms 33372 KB Output is correct
3 Correct 31 ms 33116 KB Output is correct
4 Correct 35 ms 33464 KB Output is correct
5 Correct 32 ms 33372 KB Output is correct
6 Correct 32 ms 33372 KB Output is correct
7 Correct 28 ms 33160 KB Output is correct
8 Correct 211 ms 46672 KB Output is correct
9 Correct 199 ms 40276 KB Output is correct
10 Correct 499 ms 51280 KB Output is correct
11 Correct 266 ms 52144 KB Output is correct
12 Correct 295 ms 50768 KB Output is correct
13 Correct 33 ms 33116 KB Output is correct
14 Correct 232 ms 46672 KB Output is correct
15 Correct 68 ms 34384 KB Output is correct
16 Correct 605 ms 51392 KB Output is correct
17 Correct 278 ms 51072 KB Output is correct
18 Correct 290 ms 50956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 33116 KB Output is correct
2 Correct 33 ms 33276 KB Output is correct
3 Correct 31 ms 33116 KB Output is correct
4 Correct 35 ms 33372 KB Output is correct
5 Correct 35 ms 33372 KB Output is correct
6 Correct 32 ms 33372 KB Output is correct
7 Correct 31 ms 33368 KB Output is correct
8 Correct 223 ms 46804 KB Output is correct
9 Correct 214 ms 40272 KB Output is correct
10 Correct 502 ms 51216 KB Output is correct
11 Correct 260 ms 52304 KB Output is correct
12 Correct 278 ms 50732 KB Output is correct
13 Correct 28 ms 33116 KB Output is correct
14 Correct 218 ms 46756 KB Output is correct
15 Correct 59 ms 34384 KB Output is correct
16 Correct 597 ms 51492 KB Output is correct
17 Correct 274 ms 51056 KB Output is correct
18 Correct 269 ms 50936 KB Output is correct
19 Correct 518 ms 69472 KB Output is correct
20 Correct 553 ms 67168 KB Output is correct
21 Correct 543 ms 69456 KB Output is correct
22 Correct 528 ms 67304 KB Output is correct
23 Correct 511 ms 67172 KB Output is correct
24 Correct 511 ms 67152 KB Output is correct
25 Correct 561 ms 67152 KB Output is correct
26 Correct 532 ms 69452 KB Output is correct
27 Correct 524 ms 69476 KB Output is correct
28 Correct 510 ms 67048 KB Output is correct
29 Correct 537 ms 67152 KB Output is correct
30 Correct 551 ms 67152 KB Output is correct