# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1100820 |
2024-10-14T18:44:17 Z |
Dan4Life |
Wall (IOI14_wall) |
C++17 |
|
795 ms |
59208 KB |
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)2e6+10;
const int INF = (int)1e9;
int n, q, x[mxN];
array<int,2> seg[mxN*2], Init={INF,-INF};
void apply(int p, int a, int b){
seg[p][0] = min(a, max(seg[p][0], b));
seg[p][1] = max(seg[p][1], b);
}
void prop(int p, int l, int r){
if(l==r or seg[p]==Init) return;
int mid = (l+r)/2; int rp = p+2*(mid-l+1);
auto [a,b] = seg[p]; // push down
apply(p+1,a,b), apply(rp,a,b); seg[p] = Init;
}
void upd(int i, int j, int a, int b, int p=0, int l=0, int r=n-1){
if(i>j or i>r or j<l) return;
if(i<=l and r<=j){ apply(p,a,b); return; }
prop(p,l,r);
int mid = (l+r)/2; int rp = p+2*(mid-l+1);
upd(i,j,a,b,p+1,l,mid); upd(i,j,a,b,rp,mid+1,r);
}
int query(int i, int p=0, int l=0, int r=n-1){
if(l==r) return min(seg[p][0],max(x[l],seg[p][1]));
prop(p,l,r);
int mid = (l+r)/2; int rp = p+2*(mid-l+1);
if(i<=mid) return query(i,p+1,l,mid);
return query(i,rp,mid+1,r);
}
void buildWall(int N, int k, int o[], int l[], int r[], int h[], int ans[]){
n = N; fill(seg,seg+2*n,Init);
for(int i = 0; i < k; i++){
int a, b;
if(o[i]==1) a = INF, b = h[i];
else a = h[i], b = -INF;
upd(l[i],r[i],a,b);
}
for(int i = 0; i < n; i++) ans[i] = query(i);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
5 ms |
592 KB |
Output is correct |
5 |
Correct |
5 ms |
640 KB |
Output is correct |
6 |
Correct |
4 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
83 ms |
8128 KB |
Output is correct |
3 |
Correct |
139 ms |
5960 KB |
Output is correct |
4 |
Correct |
380 ms |
11080 KB |
Output is correct |
5 |
Correct |
217 ms |
11592 KB |
Output is correct |
6 |
Correct |
215 ms |
11608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
2 ms |
520 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
5 ms |
592 KB |
Output is correct |
5 |
Correct |
5 ms |
764 KB |
Output is correct |
6 |
Correct |
5 ms |
716 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
82 ms |
8264 KB |
Output is correct |
9 |
Correct |
133 ms |
6044 KB |
Output is correct |
10 |
Correct |
387 ms |
11092 KB |
Output is correct |
11 |
Correct |
220 ms |
11532 KB |
Output is correct |
12 |
Correct |
211 ms |
11528 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
86 ms |
8148 KB |
Output is correct |
15 |
Correct |
23 ms |
3152 KB |
Output is correct |
16 |
Correct |
388 ms |
11236 KB |
Output is correct |
17 |
Correct |
219 ms |
11172 KB |
Output is correct |
18 |
Correct |
214 ms |
11124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
5 ms |
592 KB |
Output is correct |
5 |
Correct |
4 ms |
592 KB |
Output is correct |
6 |
Correct |
5 ms |
592 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
86 ms |
8192 KB |
Output is correct |
9 |
Correct |
133 ms |
5868 KB |
Output is correct |
10 |
Correct |
391 ms |
11080 KB |
Output is correct |
11 |
Correct |
226 ms |
11592 KB |
Output is correct |
12 |
Correct |
204 ms |
11600 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
84 ms |
8112 KB |
Output is correct |
15 |
Correct |
23 ms |
3152 KB |
Output is correct |
16 |
Correct |
384 ms |
11224 KB |
Output is correct |
17 |
Correct |
217 ms |
11336 KB |
Output is correct |
18 |
Correct |
211 ms |
11140 KB |
Output is correct |
19 |
Correct |
755 ms |
59204 KB |
Output is correct |
20 |
Correct |
713 ms |
56656 KB |
Output is correct |
21 |
Correct |
743 ms |
59208 KB |
Output is correct |
22 |
Correct |
757 ms |
56904 KB |
Output is correct |
23 |
Correct |
774 ms |
56900 KB |
Output is correct |
24 |
Correct |
795 ms |
56808 KB |
Output is correct |
25 |
Correct |
771 ms |
56904 KB |
Output is correct |
26 |
Correct |
733 ms |
59208 KB |
Output is correct |
27 |
Correct |
719 ms |
59208 KB |
Output is correct |
28 |
Correct |
737 ms |
56900 KB |
Output is correct |
29 |
Correct |
729 ms |
56664 KB |
Output is correct |
30 |
Correct |
764 ms |
56900 KB |
Output is correct |