#include "wall.h"
#include <bits/stdc++.h>
#define mid (l+r)/2
const int N=2e6+55;
int lazy[N*4];
int tree[N*4];
void propagate(int l , int r , int node)
{
if(lazy[node]==0)
return ;
tree[node]+=lazy[node];
// tree[node]=max(0,tree[node]);
if(l!=r)
{
lazy[node*2]+=lazy[node];
lazy[node*2+1]+=lazy[node];
}
lazy[node]=0;
}
void update(int l , int r , int node , int x , int y , int val)
{
propagate(l,r,node);
if(r<x||l>y)
return ;
if(x<=l&&r<=y)
{
lazy[node]+=val;
propagate(l,r,node);
}
update(l,mid,node*2,x,y,val);
update(mid+1,r,node*2+1,x,y,val);
}
int query(int l , int r , int node , int ind)
{
propagate(l,r,node);
if(l==r&&l==ind)
return tree[node];
if(ind<=mid)
return query(l,mid,node*2,ind);
else
return query(mid+1,r,node*2+1,ind);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
for(int i=0;i<k;i++)
{
if(op[i]==2)
height[i]*=-1;
update(0,n-1,1,right[i],left[i],height[i]);
}
for(int i=0;i<n;i++)
finalHeight[i]=query(0,n-1,1,i);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
760 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
820 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
928 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
1092 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |