# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
223945 |
2020-04-16T22:20:47 Z |
a_player |
Wall (IOI14_wall) |
C++14 |
|
172 ms |
12920 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][0];
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]);
~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
6 ms |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
172 ms |
12920 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
7 ms |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Incorrect |
7 ms |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |