# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
65484 |
2018-08-07T17:46:49 Z |
theknife2001 |
Wall (IOI14_wall) |
C++17 |
|
193 ms |
11756 KB |
#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);
return ;
}
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);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
7 ms |
616 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
616 KB |
Output is correct |
2 |
Incorrect |
193 ms |
11756 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
11756 KB |
Output is correct |
2 |
Incorrect |
5 ms |
11756 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
11756 KB |
Output is correct |
2 |
Incorrect |
5 ms |
11756 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |