# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
726776 |
2023-04-19T10:57:18 Z |
allin27x |
Wall (IOI14_wall) |
C++17 |
|
1 ms |
340 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;
SGT(int sz){
n= sz;
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<2*n) apply(p);
if (l>r) return;
if (tl==l && tr==r){
t[p][o] = h;
}
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, 2*n-1, l, r, h, o);
}
void push(){
for (int i=1; i<2*n; 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+2*n][0], st.t[i+2*n][1]);
}
Compilation message
wall.cpp: In member function 'void SGT::update(int, int, int, int, int, int, int)':
wall.cpp:31:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
31 | int tm = tl+tr>>1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
300 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |