답안 #227748

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227748 2020-04-28T16:24:43 Z 2fat2code 벽 (IOI14_wall) C++17
100 / 100
718 ms 77432 KB
#include "wall.h"
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#define sz() size()
#define fr first
#define sc second
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
//#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;

const int nmax=2000005;

int u[4*nmax],d[4*nmax],ans[nmax],lazy[4*nmax];

void lazi(int nod,int up,int down){
    d[nod]=min(d[nod],down);
    d[nod]=max(d[nod],up);
    u[nod]=max(u[nod],up);
    u[nod]=min(u[nod],down);
}

void update(int l,int r,int le,int ri,int op,int h,int nod){
    if(l>ri || r<le) return;
    else if(l>=le && r<=ri){
        if(op==1){
            u[nod]=max(u[nod],h);
            d[nod]=max(d[nod],h);
        }
        else{
            u[nod]=min(u[nod],h);
            d[nod]=min(d[nod],h);
        }
    }
    else{
        lazi(2*nod,u[nod],d[nod]);
        lazi(2*nod+1,u[nod],d[nod]);
        u[nod]=0;
        d[nod]=1e18;
        int mid=l+(r-l)/2;
        update(l,mid,le,ri,op,h,2*nod);
        update(mid+1,r,le,ri,op,h,2*nod+1);
    }
}

void complete(int l,int r,int nod){
    if(l!=r){
        int mid=l+(r-l)/2;
        lazi(2*nod,u[nod],d[nod]);
        lazi(2*nod+1,u[nod],d[nod]);
        complete(l,mid,2*nod);
        complete(mid+1,r,2*nod+1);
    }
    else{
        ans[l]=min(u[nod],d[nod]);
    }
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
   // for(int i=1;i<=4*n;i++) d[i]=1e18;
    for(int i=1;i<=k;i++){
        update(1,n,left[i-1]+1,right[i-1]+1,op[i-1],height[i-1],1);
    }
    complete(1,n,1);
    for(int i=1;i<=n;i++) finalHeight[i-1]=ans[i];
}

Compilation message

wall.cpp: In function 'void update(int, int, int, int, int, int, int)':
wall.cpp:46:16: warning: overflow in implicit constant conversion [-Woverflow]
         d[nod]=1e18;
                ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 10 ms 896 KB Output is correct
5 Correct 9 ms 896 KB Output is correct
6 Correct 10 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 179 ms 13944 KB Output is correct
3 Correct 177 ms 8056 KB Output is correct
4 Correct 483 ms 20848 KB Output is correct
5 Correct 319 ms 21880 KB Output is correct
6 Correct 303 ms 20472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 10 ms 896 KB Output is correct
5 Correct 9 ms 896 KB Output is correct
6 Correct 9 ms 896 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 182 ms 13956 KB Output is correct
9 Correct 177 ms 8160 KB Output is correct
10 Correct 494 ms 20860 KB Output is correct
11 Correct 314 ms 21840 KB Output is correct
12 Correct 316 ms 20344 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 180 ms 13944 KB Output is correct
15 Correct 34 ms 2168 KB Output is correct
16 Correct 492 ms 21112 KB Output is correct
17 Correct 299 ms 20472 KB Output is correct
18 Correct 313 ms 20728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 10 ms 896 KB Output is correct
5 Correct 9 ms 896 KB Output is correct
6 Correct 9 ms 896 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 187 ms 14120 KB Output is correct
9 Correct 180 ms 8184 KB Output is correct
10 Correct 479 ms 20776 KB Output is correct
11 Correct 316 ms 21880 KB Output is correct
12 Correct 293 ms 20344 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 179 ms 14072 KB Output is correct
15 Correct 33 ms 2172 KB Output is correct
16 Correct 493 ms 21112 KB Output is correct
17 Correct 309 ms 20476 KB Output is correct
18 Correct 305 ms 20476 KB Output is correct
19 Correct 702 ms 77432 KB Output is correct
20 Correct 710 ms 75000 KB Output is correct
21 Correct 699 ms 77432 KB Output is correct
22 Correct 699 ms 75000 KB Output is correct
23 Correct 680 ms 74848 KB Output is correct
24 Correct 685 ms 74872 KB Output is correct
25 Correct 704 ms 75128 KB Output is correct
26 Correct 718 ms 77376 KB Output is correct
27 Correct 704 ms 77432 KB Output is correct
28 Correct 706 ms 74872 KB Output is correct
29 Correct 704 ms 75000 KB Output is correct
30 Correct 689 ms 75000 KB Output is correct