#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
const int mxN = (int)2.5e5+10;
const int LINF = (int)1e18;
int n, m, q, segTree[mxN*2];
pair<int,int> lazy[mxN*2];
void prop(int p, int l, int r){
if(l==r or lazy[p].se==-1) return;
int mid = (l+r)>>1; int rp = p+2*(mid-l+1);
lazy[p+1] = lazy[p];
segTree[p+1] = max(segTree[p+1]+lazy[p+1].fi,lazy[p+1].se);
int xd = p; p = rp-1;
lazy[p+1] = lazy[p];
segTree[p+1] = max(segTree[p+1]+lazy[p+1].fi,lazy[p+1].se);
p = xd; lazy[p] = {-1,-1};
}
void upd(int i, int j, int v, int p=0, int l=1, int r=n){
if(i>r or j<l or i>j) return; prop(p,l,r);
if(i<=l and r<=j){
segTree[p]+=v;
if(v>=0) lazy[p] = {v,-LINF};
else lazy[p] = {v,0};
segTree[p]=max(segTree[p],lazy[p].se);
return;
}
int mid = (l+r)>>1; int rp = p+2*(mid-l+1);
if(i<=mid) upd(i,j,v,p+1,l,mid);
if(j>mid) upd(i,j,v,rp,mid+1,r);
}
int query(int i, int p=0, int l=1, int r=n){
prop(p,l,r);
if(l==r) return segTree[p];
int mid = (l+r)>>1; int rp = p+2*(mid-l+1);
if(i<=mid) return query(i,p+1,l,mid);
return query(i,rp,mid+1,r);
}
struct SegTree{
int segTree[mxN*2], lazy[mxN*2];
void prop(int p, int l, int r){
if(l==r or !lazy[p]) return;
int mid = (l+r)>>1; int rp = p+2*(mid-l+1);
lazy[p+1]+=lazy[p]; lazy[rp]+=lazy[p]; lazy[p]=0;
segTree[p+1]+=lazy[p+1]*(mid-l+1);
segTree[rp]+=lazy[rp]*(r-mid);
}
void upd(int i, int j, int v, int p=0, int l=1, int r=n){
if(i>r or j<l or i>j) return; prop(p,l,r);
if(i<=l and r<=j){ segTree[p]+=v; lazy[p]+=v; return; }
int mid = (l+r)>>1; int rp = p+2*(mid-l+1);
if(i<=mid) upd(i,j,v,p+1,l,mid);
if(j>mid) upd(i,j,v,rp,mid+1,r);
}
int query(int i, int p=0, int l=1, int r=n){
prop(p,l,r);
if(l==r) return segTree[p];
int mid = (l+r)>>1; int rp = p+2*(mid-l+1);
if(i<=mid) return query(i,p+1,l,mid);
return query(i,rp,mid+1,r);
}
} seg;
int32_t main() {
cin >> n >> m >> q;
for(int i = 0; i < mxN*2; i++) lazy[i] = {-1,-1};
for(int i = 0; i < q; i++){
int t, l, r, a, b, c, k; cin >> t;
if(t==1){
cin >> l >> r >> c >> k;
upd(l,r,k); seg.upd(l,r,k);
}
else if(t==2){
cin >> l >> r >> k;
upd(l,r,-k);
}
else{
cin >> a >> b;
cout << (seg.query(a)>=query(a)+b) << "\n";
}
}
}
Compilation message
foodcourt.cpp: In function 'void upd(long long int, long long int, long long int, long long int, long long int, long long int)':
foodcourt.cpp:25:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
25 | if(i>r or j<l or i>j) return; prop(p,l,r);
| ^~
foodcourt.cpp:25:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
25 | if(i>r or j<l or i>j) return; prop(p,l,r);
| ^~~~
foodcourt.cpp: In member function 'void SegTree::upd(long long int, long long int, long long int, long long int, long long int, long long int)':
foodcourt.cpp:58:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
58 | if(i>r or j<l or i>j) return; prop(p,l,r);
| ^~
foodcourt.cpp:58:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
58 | if(i>r or j<l or i>j) return; prop(p,l,r);
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
8148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
8148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
174 ms |
11220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
720 ms |
24116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
8148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
177 ms |
11236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
8148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
8148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |