답안 #208316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
208316 2020-03-10T17:00:18 Z Lukoloz 벽 (IOI14_wall) C++14
100 / 100
946 ms 92076 KB
#include <bits/stdc++.h>
#include "wall.h"
#define ll long long
#define MAXN 2000005
#define ff first
#define ss second
#define INF 999999999
using namespace std;
int l[3*MAXN],r[3*MAXN],xl,xr,xi;
pair <int,int> st[3*MAXN],cp;
void buil(int i){
    st[i]={0,INF};
    if (l[i]==r[i]) return;
    l[i*2]=l[i]; r[i*2]=(l[i]+r[i])/2;
    l[i*2+1]=r[i*2]+1; r[i*2+1]=r[i];
    buil(i*2); buil(i*2+1);
}
pair<int,int> cramb(pair<int,int> p1, pair<int,int> p2){
    pair<int,int> tp;
    tp={max(p1.ff,p2.ff),min(p1.ss,p2.ss)};
    if (tp.ff<=tp.ss) return tp;
    if (p2.ff>p1.ss) return {p2.ff,p2.ff};
    else return {p2.ss,p2.ss};
}
void add(int i){
    if (l[i]>xr || r[i]<xl) return;
    if (l[i]>=xl && r[i]<=xr){
        st[i]=cramb(st[i],cp);
        return;
    }
    st[i*2]=cramb(st[i*2],st[i]);
    st[i*2+1]=cramb(st[i*2+1],st[i]);
    st[i]={0,INF};
    add(i*2); add(i*2+1);
}
int ret(int i){
    if (l[i]==r[i]){
        return cramb({0,0},st[i]).ff;
    }
    int tret;
    if (xi<=r[i*2]) tret=ret(i*2);
    else tret=ret(i*2+1);
    return cramb({tret,tret},st[i]).ff;
}
void buildWall(int n, int k, int op[], int left[], int right[],int height[], int finalHeight[]){
    l[1]=0,r[1]=n-1;
    buil(1);
    for (int i=0; i<k; i++){
        xl=left[i],xr=right[i];
        if (op[i]==1) cp={height[i],INF};
        else cp={0,height[i]};
        add(1);
    }
    for (int i=0; i<n; i++){
        xi=i;
        finalHeight[i]=ret(1);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 12 ms 1016 KB Output is correct
5 Correct 10 ms 1016 KB Output is correct
6 Correct 10 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 184 ms 8160 KB Output is correct
3 Correct 183 ms 4728 KB Output is correct
4 Correct 504 ms 12920 KB Output is correct
5 Correct 309 ms 13372 KB Output is correct
6 Correct 298 ms 13432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 13 ms 1016 KB Output is correct
5 Correct 10 ms 1016 KB Output is correct
6 Correct 11 ms 1016 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 190 ms 8160 KB Output is correct
9 Correct 181 ms 4728 KB Output is correct
10 Correct 513 ms 12920 KB Output is correct
11 Correct 299 ms 13436 KB Output is correct
12 Correct 294 ms 13384 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 189 ms 8184 KB Output is correct
15 Correct 42 ms 2044 KB Output is correct
16 Correct 672 ms 13160 KB Output is correct
17 Correct 315 ms 13176 KB Output is correct
18 Correct 312 ms 13176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 380 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 12 ms 1016 KB Output is correct
5 Correct 10 ms 1016 KB Output is correct
6 Correct 11 ms 1016 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 183 ms 8184 KB Output is correct
9 Correct 176 ms 4728 KB Output is correct
10 Correct 492 ms 12920 KB Output is correct
11 Correct 314 ms 13464 KB Output is correct
12 Correct 298 ms 13432 KB Output is correct
13 Correct 5 ms 380 KB Output is correct
14 Correct 192 ms 8296 KB Output is correct
15 Correct 43 ms 2040 KB Output is correct
16 Correct 686 ms 13284 KB Output is correct
17 Correct 315 ms 13176 KB Output is correct
18 Correct 317 ms 13336 KB Output is correct
19 Correct 919 ms 91996 KB Output is correct
20 Correct 902 ms 89612 KB Output is correct
21 Correct 920 ms 92024 KB Output is correct
22 Correct 918 ms 89472 KB Output is correct
23 Correct 923 ms 89592 KB Output is correct
24 Correct 932 ms 89592 KB Output is correct
25 Correct 907 ms 89720 KB Output is correct
26 Correct 927 ms 92024 KB Output is correct
27 Correct 932 ms 92076 KB Output is correct
28 Correct 946 ms 89520 KB Output is correct
29 Correct 894 ms 89592 KB Output is correct
30 Correct 903 ms 89592 KB Output is correct