# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
514502 | enerelt14 | Wall (IOI14_wall) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int n, q;
struct node{
int lazy, mn, mx;
node(){
lazy=-1;
mn=0;
mx=0;
}
};
node tree[8000005];
void propagate(int id, int l, int r){
if (l==r)return;
if (tree[id].lazy!=-1){
tree[id*2+1].lazy=tree[id].lazy;
tree[id*2+2].lazy=tree[id].lazy;
tree[id*2+1].mn=tree[id].lazy;
tree[id*2+1].mx=tree[id].lazy;
tree[id*2+2].mn=tree[id].lazy;
tree[id*2+2].mx=tree[id].lazy;
}
tree[id].mn=min(tree[id*2+1].mn, tree[id*2+2].mn);
tree[id].mx=max(tree[id*2+1].mx, tree[id*2+2].mx);
tree[id].lazy=-1;
}
void update1(int id, int l, int r, int L, int R, int h){
if (L>r || l>R || tree[id].mn>=h)return;
if (L<=l && r<=R && tree[id].mn==tree[id].mx){
tree[id].lazy=max(tree[id].lazy, h);
tree[id].mn=max(tree[id].mn, h);
tree[id].mx=max(tree[id].mx, h);
//cout<<id<<" "<<l<<" "<<r<<" "<<tree[id].lazy<<" "<<tree[id].mn<<" "<<tree[id].mx<<"\n";
return;
}
propagate(id, l, r);
int m=(l+r)/2;
update1(id*2+1, l, m, L, R, h);
update1(id*2+2, m+1, r, L, R, h);
tree[id].mn=min(tree[id*2+1].mn, tree[id*2+2].mn);
tree[id].mx=max(tree[id*2+1].mx, tree[id*2+2].mx);
}
void update2(int id, int l, int r, int L, int R, int h){
if (L>r || l>R || tree[id].mx<=h)return;
if (L<=l && r<=R && tree[id].mn==tree[id].mx){
if (tree[id].lazy!=-1)tree[id].lazy=min(tree[id].lazy, h);
else tree[id].lazy=h;
tree[id].mn=min(tree[id].mn, h);
tree[id].mx=min(tree[id].mx, h);
//cout<<id<<" "<<l<<" "<<r<<" "<<tree[id].lazy<<" "<<tree[id].mn<<" "<<tree[id].mx<<"\n";
return;
}
propagate(id, l, r);
int m=(l+r)/2;
update2(id*2+1, l, m, L, R, h);
update2(id*2+2, m+1, r, L, R, h);
tree[id].mn=min(tree[id*2+1].mn, tree[id*2+2].mn);
tree[id].mx=max(tree[id*2+1].mx, tree[id*2+2].mx);
}
void solve(int id, int l, int r){
propagate(id, l, r);
if (l==r){
cout<<tree[id].mn<<"\n";
return;
}
int m=(l+r)/2;
solve(id*2+1, l, m);
solve(id*2+2, m+1, r);
}
int main(){
cin>>n>>q;
while(q--){
int x, y, z, t;
cin>>x>>y>>z>>t;
if (x==1)update1(0, 0, n-1, y, z, t);
else update2(0, 0, n-1, y, z, t);
}
solve(0, 0, n-1);
}