#include<bits/stdc++.h>
using namespace std;
const int nax = 250003;
int n, m, q;
pair<long long, long long>st[nax * 4];
void unlazy(int v) {
for(int c : {v*2, v*2+1}) {
long long val = st[v].second;
long long cut = min(val, st[c].first);
st[c].first -= cut, val -= cut;
st[c].second += val;
st[c].first += st[v].first;
}
st[v] = {0LL, 0LL};
}
void add(int l, int r, int L, int R, long long del, int v) {
if(l>R || r<L) return;
if(l>=L && r<=R) {
st[v].first += del;
return;
}
unlazy(v);
int mid = (l+r)/2;
add(l, mid, L, R, del, v*2);
add(mid+1, r, L, R, del, v*2+1);
}
void sub(int l, int r, int L, int R, long long del, int v) {
if(l>R || r<L) return;
if(l>=L && r<=R) {
long long cut = min(st[v].first, del);
st[v].first -= cut, del -= cut;
st[v].second += del;
return;
}
unlazy(v);
int mid = (l+r)/2;
sub(l, mid, L, R, del, v*2);
sub(mid+1, r, L, R, del, v*2+1);
}
long long query(int l, int r, int p, int v) {
if(l==r) {
return st[v].first;
}
unlazy(v);
int mid = (l+r)/2;
if(p<=mid) return query(l, mid, p, v*2);
else return query(mid+1, r, p, v*2+1);
}
void PlayGround() {
cin>>n>>m>>q;
while(q--) {
int tp;
cin>>tp;
if(tp==1) {
long long l, r, c, k;
cin>>l>>r>>c>>k;
add(1, n, l, r, k, 1);
} else if(tp==2) {
long long l, r, k;
cin>>l>>r>>k;
sub(1, n, l, r, k, 1);
} else {
long long a, b;
cin>>a>>b;
long long cur = query(1, n, a, 1);
if(cur>=b) cout<<"1\n";
else cout<<"0\n";
}
}
// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
46 ms |
3536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
220 ms |
14012 KB |
Output is correct |
2 |
Correct |
165 ms |
12800 KB |
Output is correct |
3 |
Correct |
247 ms |
14600 KB |
Output is correct |
4 |
Correct |
178 ms |
13008 KB |
Output is correct |
5 |
Correct |
186 ms |
13156 KB |
Output is correct |
6 |
Correct |
257 ms |
14788 KB |
Output is correct |
7 |
Correct |
67 ms |
4524 KB |
Output is correct |
8 |
Correct |
74 ms |
4548 KB |
Output is correct |
9 |
Correct |
209 ms |
14796 KB |
Output is correct |
10 |
Correct |
220 ms |
14816 KB |
Output is correct |
11 |
Correct |
239 ms |
14680 KB |
Output is correct |
12 |
Correct |
242 ms |
14668 KB |
Output is correct |
13 |
Correct |
251 ms |
14644 KB |
Output is correct |
14 |
Correct |
250 ms |
14624 KB |
Output is correct |
15 |
Correct |
278 ms |
14600 KB |
Output is correct |
16 |
Correct |
233 ms |
14540 KB |
Output is correct |
17 |
Correct |
237 ms |
14572 KB |
Output is correct |
18 |
Correct |
252 ms |
14644 KB |
Output is correct |
19 |
Correct |
233 ms |
14668 KB |
Output is correct |
20 |
Correct |
250 ms |
14656 KB |
Output is correct |
21 |
Correct |
239 ms |
14664 KB |
Output is correct |
22 |
Correct |
241 ms |
14564 KB |
Output is correct |
23 |
Correct |
274 ms |
14736 KB |
Output is correct |
24 |
Correct |
250 ms |
14744 KB |
Output is correct |
25 |
Correct |
208 ms |
14140 KB |
Output is correct |
26 |
Correct |
209 ms |
14376 KB |
Output is correct |
27 |
Correct |
201 ms |
14280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
41 ms |
3796 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |