답안 #223946

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
223946 2020-04-16T22:21:35 Z a_player 벽 (IOI14_wall) C++14
0 / 100
176 ms 8184 KB
#include <bits/stdc++.h>

using namespace std;
#define fh finalHeight

const int nax=2e6+6;
const int inf=2e9;

int rt[2*nax][2];
int n;
void updatem(int l, int r, int val){
    l+=n,r+=n;
    while(l<=r){
        if(l%2==1){
            rt[l][0]=min(rt[l][0],val);
            rt[l][1]=min(rt[l][0],rt[l++][1]);
        }
        if(r%2==0){
            rt[r][0]=min(rt[r][0],val);
            rt[r][1]=min(rt[r][0],rt[r--][1]);
        }
        l/=2,r/=2;
    }
}
void updateM(int l, int r, int val){
    l+=n,r+=n;
    while(l<=r){
        if(l%2==1){
            rt[l][1]=max(rt[l][1],val);
            rt[l][0]=max(rt[l][0],rt[l++][1]);
        }
        if(r%2==0){
            rt[r][1]=max(rt[r][1],val);
            rt[r][0]=max(rt[r][0],rt[r--][1]);
        }
        l/=2,r/=2;
    }
}
int query(int p){
    p+=n;
    int mini=rt[p][0];
    int mas=rt[p][1];
    for(p/=2;p>=1;p/=2){
        mini=min(mini,rt[p][0]);
        mas=min(mas,mini);
        mas=max(mas,rt[p][1]);
        mini=max(mas,mini);
    }
    return mini;
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    ::n=n;
    for(int i=0;i<2*n;i++)rt[i][0]=inf;
        for(int i=0;i<k;i++){
            if(op[i]==1)updatem(left[i],right[i],height[i]);

            else updateM(left[i],right[i],height[i]);
        }
        for(int i=0;i<n;i++)fh[i]=query(i);
}

Compilation message

wall.cpp: In function 'void updatem(int, int, int)':
wall.cpp:16:39: warning: operation on 'l' may be undefined [-Wsequence-point]
             rt[l][1]=min(rt[l][0],rt[l++][1]);
                                      ~^~
wall.cpp:20:39: warning: operation on 'r' may be undefined [-Wsequence-point]
             rt[r][1]=min(rt[r][0],rt[r--][1]);
                                      ~^~
wall.cpp: In function 'void updateM(int, int, int)':
wall.cpp:30:39: warning: operation on 'l' may be undefined [-Wsequence-point]
             rt[l][0]=max(rt[l][0],rt[l++][1]);
                                      ~^~
wall.cpp:34:39: warning: operation on 'r' may be undefined [-Wsequence-point]
             rt[r][0]=max(rt[r][0],rt[r--][1]);
                                      ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 6 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 176 ms 8184 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 6 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Incorrect 6 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -