#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++][1],val);
}
if(r%2==0){
rt[r][0]=min(rt[r][0],val);
rt[r][1]=min(rt[r--][1],val);
}
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);
}
if(r%2==0){
rt[r][1]=max(rt[r--][1],val);
}
l/=2,r/=2;
}
}
int query(int p){
p+=n;
int ans=rt[p][1];
for(p/=2;p>=1;p/=2){
ans=min(ans,rt[p][0]);
ans=max(ans,rt[p][1]);
}
return ans;
}
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:30: warning: operation on 'l' may be undefined [-Wsequence-point]
rt[l][1]=min(rt[l++][1],val);
~^~
wall.cpp:20:30: warning: operation on 'r' may be undefined [-Wsequence-point]
rt[r][1]=min(rt[r--][1],val);
~^~
wall.cpp: In function 'void updateM(int, int, int)':
wall.cpp:29:30: warning: operation on 'l' may be undefined [-Wsequence-point]
rt[l][1]=max(rt[l++][1],val);
~^~
wall.cpp:32:30: warning: operation on 'r' may be undefined [-Wsequence-point]
rt[r][1]=max(rt[r--][1],val);
~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
128 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |