# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
726811 |
2023-04-19T11:47:56 Z |
allin27x |
Wall (IOI14_wall) |
C++17 |
|
1033 ms |
262144 KB |
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long int;
struct SGT{
vector<vector<int>> t;
int n;
int ofs;
SGT(int sz){
n= sz;
ofs = 1ll<<(int)(ceil(log2(n+1)));
t.resize(4*n, {0, (int)2e9});
}
void apply(int p){
if (t[p][0]>t[2*p][1]) t[2*p][0]=t[p][0],t[2*p][1]=t[p][0]; else
if (t[2*p][0]>t[p][1]) t[2*p][0]=t[p][1], t[2*p][1]=t[p][1]; else
t[2*p][0]=max(t[2*p][0],t[p][0]), t[2*p][1]=min(t[2*p][1], t[p][1]);
if (t[p][0]>t[2*p+1][1]) t[2*p+1][0]=t[p][0],t[2*p+1][1]=t[p][0]; else
if (t[2*p+1][0]>t[p][1]) t[2*p+1][0]=t[p][1], t[2*p+1][1]=t[p][1]; else
t[2*p+1][0]=max(t[2*p+1][0],t[p][0]), t[2*p+1][1]=min(t[2*p+1][1], t[p][1]);
t[p][0] = 0; t[p][1] = (int)2e9;
}
void update(int p, int tl, int tr, int l ,int r, int h, int o){
if (p<ofs) apply(p);
if (l>r) return;
if (tl==l && tr==r){
if (o==0){
t[p][0] = max(t[p][0], h); t[p][1] = max(t[p][1], t[p][0]);
} else {
t[p][1] = min(t[p][1], h); t[p][0] = min(t[p][0], t[p][1]);
}
return;
}
int tm = (tl+tr)>>1;
update(2*p, tl, tm, l, min(tm, r), h, o);
update(2*p+1, tm+1, tr, max(l,tm+1), r, h, o);
}
void update(int l, int r, int h, int o){
update(1, 0, ofs-1, l, r, h, o);
}
void push(){
for (int i=1; i<ofs; i++){
apply(i);
}
}
};
void buildWall(int n, int k, int op[], int l[],int r[],int h[], int ans[]){
SGT st(n);
for (int i=0; i<k; i++){
st.update(l[i], r[i], h[i], op[i]-1);
}
st.push();
for (int i=0; i<n; i++) ans[i] = min(st.t[i+st.ofs][0], st.t[i+st.ofs][1]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
10 ms |
2772 KB |
Output is correct |
5 |
Correct |
8 ms |
2616 KB |
Output is correct |
6 |
Correct |
8 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
130 ms |
8100 KB |
Output is correct |
3 |
Correct |
217 ms |
10060 KB |
Output is correct |
4 |
Correct |
861 ms |
39940 KB |
Output is correct |
5 |
Correct |
345 ms |
40684 KB |
Output is correct |
6 |
Correct |
336 ms |
39040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
10 ms |
2644 KB |
Output is correct |
5 |
Correct |
8 ms |
2644 KB |
Output is correct |
6 |
Correct |
8 ms |
2612 KB |
Output is correct |
7 |
Correct |
1 ms |
304 KB |
Output is correct |
8 |
Correct |
127 ms |
13872 KB |
Output is correct |
9 |
Correct |
213 ms |
11320 KB |
Output is correct |
10 |
Correct |
796 ms |
40048 KB |
Output is correct |
11 |
Correct |
351 ms |
40700 KB |
Output is correct |
12 |
Correct |
330 ms |
38928 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
132 ms |
14016 KB |
Output is correct |
15 |
Correct |
45 ms |
5120 KB |
Output is correct |
16 |
Correct |
1033 ms |
40032 KB |
Output is correct |
17 |
Correct |
342 ms |
39464 KB |
Output is correct |
18 |
Correct |
343 ms |
39464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
9 ms |
2644 KB |
Output is correct |
5 |
Correct |
7 ms |
2616 KB |
Output is correct |
6 |
Correct |
8 ms |
2672 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
132 ms |
13892 KB |
Output is correct |
9 |
Correct |
203 ms |
11368 KB |
Output is correct |
10 |
Correct |
812 ms |
40040 KB |
Output is correct |
11 |
Correct |
351 ms |
40524 KB |
Output is correct |
12 |
Correct |
339 ms |
39024 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
128 ms |
13904 KB |
Output is correct |
15 |
Correct |
46 ms |
5112 KB |
Output is correct |
16 |
Correct |
977 ms |
40096 KB |
Output is correct |
17 |
Correct |
331 ms |
39376 KB |
Output is correct |
18 |
Correct |
341 ms |
39568 KB |
Output is correct |
19 |
Runtime error |
351 ms |
262144 KB |
Execution killed with signal 9 |
20 |
Halted |
0 ms |
0 KB |
- |