#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
struct Node
{
int ch,ty;
Node()
{
ch = 0;
ty = 0;
};
Node(int chi, int ti)
{
ch = chi;
ty = ti;
}
};
const int maxn = 2e5+5;
int type,ql,qr,val;
Node lazy[4*maxn];
int tree[maxn];
void push_lazy(int v, int l, int r)
{
if(lazy[v].ty==0) return;
if(l==r)
{
if(lazy[v].ty==1) tree[r] = max(tree[r],lazy[v].ch);
else tree[r] = min(tree[r],lazy[v].ch);
}
else
{
lazy[v*2+0] = lazy[v];
lazy[v*2+1] = lazy[v];
}
lazy[v].ch = 0;
lazy[v].ty = 0;
}
void query(int v, int l, int r)
{
///
if(l!=r)
{
int mid = (l+r)/2;
push_lazy(v*2+0,l,mid+0);
push_lazy(v*2+1,mid+1,r);
}
push_lazy(v,l,r);
if(l!=r)
{
int mid = (l+r)/2;
push_lazy(v*2+0,l,mid+0);
push_lazy(v*2+1,mid+1,r);
}
///
if(l==r) return;
int mid = (l+r)/2;
if(qr<=mid) query(v*2+0,l,mid+0);
else query(v*2+1,mid+1,r);
}
void update(int v, int l, int r)
{
///
if(l!=r)
{
int mid = (l+r)/2;
push_lazy(v*2+0,l,mid+0);
push_lazy(v*2+1,mid+1,r);
}
push_lazy(v,l,r);
if(l!=r)
{
int mid = (l+r)/2;
push_lazy(v*2+0,l,mid+0);
push_lazy(v*2+1,mid+1,r);
}
///
if(r<ql||qr<l||l>r) return;
if(ql<=l&&r<=qr)
{
lazy[v] = {val,type};
///
push_lazy(v,l,r);
if(l!=r)
{
int mid = (l+r)/2;
push_lazy(v*2+0,l,mid+0);
push_lazy(v*2+1,mid+1,r);
}
///
return;
}
int mid = (l+r)/2;
update(v*2+0,l,mid+0);
update(v*2+1,mid+1,r);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
for(int i = 0; i < k; i++)
{
type = op[i];
ql = left[i];
qr = right[i];
val = height[i];
for(int j = ql; j <= qr; j++)
{
if(type==1) tree[j] = max(tree[j],val);
else tree[j] = min(tree[j],val);
}
}
for(int i = 0; i < n; i++) finalHeight[i] = tree[i];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
7260 KB |
Output is correct |
2 |
Correct |
2 ms |
7260 KB |
Output is correct |
3 |
Correct |
2 ms |
7260 KB |
Output is correct |
4 |
Correct |
12 ms |
7544 KB |
Output is correct |
5 |
Correct |
13 ms |
7512 KB |
Output is correct |
6 |
Correct |
12 ms |
7544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
7256 KB |
Output is correct |
2 |
Correct |
98 ms |
14932 KB |
Output is correct |
3 |
Correct |
697 ms |
10528 KB |
Output is correct |
4 |
Execution timed out |
3062 ms |
20372 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
7260 KB |
Output is correct |
2 |
Correct |
2 ms |
7344 KB |
Output is correct |
3 |
Correct |
2 ms |
7260 KB |
Output is correct |
4 |
Correct |
13 ms |
7552 KB |
Output is correct |
5 |
Correct |
16 ms |
7552 KB |
Output is correct |
6 |
Correct |
13 ms |
7548 KB |
Output is correct |
7 |
Correct |
2 ms |
7256 KB |
Output is correct |
8 |
Correct |
92 ms |
18184 KB |
Output is correct |
9 |
Correct |
775 ms |
12732 KB |
Output is correct |
10 |
Execution timed out |
3018 ms |
20704 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
7260 KB |
Output is correct |
2 |
Correct |
2 ms |
7356 KB |
Output is correct |
3 |
Correct |
2 ms |
7092 KB |
Output is correct |
4 |
Correct |
13 ms |
7516 KB |
Output is correct |
5 |
Correct |
13 ms |
7516 KB |
Output is correct |
6 |
Correct |
13 ms |
7548 KB |
Output is correct |
7 |
Correct |
1 ms |
7256 KB |
Output is correct |
8 |
Correct |
81 ms |
18052 KB |
Output is correct |
9 |
Correct |
696 ms |
12736 KB |
Output is correct |
10 |
Execution timed out |
3009 ms |
20228 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |