# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
565384 |
2022-05-20T20:28:35 Z |
n0sk1ll |
벽 (IOI14_wall) |
C++14 |
|
786 ms |
118828 KB |
#include "wall.h"
#include <bits/stdc++.h>
#define ff(i,a,b) for (int i=a;i<b;i++)
#define bff(i,a,b) for (int i=b-1;i>=a;i--)
using namespace std;
const int mod=1000000007;
int k=1;
int val[4444444];
int l[4444444],r[4444444];
int minw[4444444],maxw[4444444];
void Build(int n)
{
while (k<n) k*=2;
ff(i,0,k) l[i+k]=i,r[i+k]=i;
bff(i,1,k) l[i]=l[2*i],r[i]=r[2*i+1];
ff(i,1,2*k) minw[i]=mod,maxw[i]=-mod;
}
void Upd(int p)
{
val[p]=min(val[p],minw[p]);
val[p]=max(val[p],maxw[p]);
if (p<k)
{
minw[2*p]=min(minw[2*p],minw[p]);
minw[2*p+1]=min(minw[2*p+1],minw[p]);
maxw[2*p]=min(maxw[2*p],minw[p]);
maxw[2*p+1]=min(maxw[2*p+1],minw[p]);
minw[2*p]=max(minw[2*p],maxw[p]);
minw[2*p+1]=max(minw[2*p+1],maxw[p]);
maxw[2*p]=max(maxw[2*p],maxw[p]);
maxw[2*p+1]=max(maxw[2*p+1],maxw[p]);
}
minw[p]=mod,maxw[p]=-mod;
}
void Minw(int p, int ll, int rr, int x)
{
if (ll>r[p] || rr<l[p]);
else if (ll<=l[p] && rr>=r[p]) minw[p]=min(minw[p],x),maxw[p]=min(maxw[p],x),Upd(p);
else Upd(p),Minw(2*p,ll,rr,x),Minw(2*p+1,ll,rr,x);
}
void Maxw(int p, int ll, int rr, int x)
{
if (ll>r[p] || rr<l[p]);
else if (ll<=l[p] && rr>=r[p]) maxw[p]=max(maxw[p],x),minw[p]=max(minw[p],x),Upd(p);
else Upd(p),Maxw(2*p,ll,rr,x),Maxw(2*p+1,ll,rr,x);
}
void buildWall(int n, int q, int op[], int left[], int right[], int height[], int finalHeight[])
{
Build(n);
ff(i,0,q)
{
if (op[i]==1) Maxw(1,left[i],right[i],height[i]);
else Minw(1,left[i],right[i],height[i]);
}
ff(i,1,2*k) Upd(i);
ff(i,0,n) finalHeight[i]=val[i+k];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
456 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
6 ms |
1216 KB |
Output is correct |
5 |
Correct |
6 ms |
1148 KB |
Output is correct |
6 |
Correct |
6 ms |
1236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
145 ms |
13980 KB |
Output is correct |
3 |
Correct |
192 ms |
8760 KB |
Output is correct |
4 |
Correct |
571 ms |
23480 KB |
Output is correct |
5 |
Correct |
290 ms |
24652 KB |
Output is correct |
6 |
Correct |
304 ms |
22996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
452 KB |
Output is correct |
3 |
Correct |
2 ms |
372 KB |
Output is correct |
4 |
Correct |
6 ms |
1236 KB |
Output is correct |
5 |
Correct |
5 ms |
1236 KB |
Output is correct |
6 |
Correct |
5 ms |
1100 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
145 ms |
13928 KB |
Output is correct |
9 |
Correct |
181 ms |
8772 KB |
Output is correct |
10 |
Correct |
589 ms |
23484 KB |
Output is correct |
11 |
Correct |
294 ms |
24544 KB |
Output is correct |
12 |
Correct |
286 ms |
23064 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
157 ms |
13984 KB |
Output is correct |
15 |
Correct |
29 ms |
2808 KB |
Output is correct |
16 |
Correct |
531 ms |
23856 KB |
Output is correct |
17 |
Correct |
293 ms |
23164 KB |
Output is correct |
18 |
Correct |
284 ms |
23232 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
448 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
7 ms |
1152 KB |
Output is correct |
5 |
Correct |
5 ms |
1236 KB |
Output is correct |
6 |
Correct |
5 ms |
1236 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
136 ms |
13916 KB |
Output is correct |
9 |
Correct |
189 ms |
8756 KB |
Output is correct |
10 |
Correct |
519 ms |
23488 KB |
Output is correct |
11 |
Correct |
285 ms |
24668 KB |
Output is correct |
12 |
Correct |
315 ms |
22972 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
136 ms |
14028 KB |
Output is correct |
15 |
Correct |
29 ms |
2708 KB |
Output is correct |
16 |
Correct |
588 ms |
23740 KB |
Output is correct |
17 |
Correct |
306 ms |
23168 KB |
Output is correct |
18 |
Correct |
281 ms |
23096 KB |
Output is correct |
19 |
Correct |
765 ms |
118812 KB |
Output is correct |
20 |
Correct |
755 ms |
116480 KB |
Output is correct |
21 |
Correct |
776 ms |
118784 KB |
Output is correct |
22 |
Correct |
754 ms |
116504 KB |
Output is correct |
23 |
Correct |
769 ms |
116264 KB |
Output is correct |
24 |
Correct |
754 ms |
116368 KB |
Output is correct |
25 |
Correct |
768 ms |
116452 KB |
Output is correct |
26 |
Correct |
786 ms |
118740 KB |
Output is correct |
27 |
Correct |
765 ms |
118828 KB |
Output is correct |
28 |
Correct |
741 ms |
116248 KB |
Output is correct |
29 |
Correct |
745 ms |
116468 KB |
Output is correct |
30 |
Correct |
758 ms |
116240 KB |
Output is correct |