#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAX_N = 3e5;
long long v[MAX_N + 1];
struct SegTree {
struct info {
long long sum, minn;
info operator + ( info &x ) {
info ans;
ans.minn = min( minn, sum + x.minn );
ans.sum = sum + x.sum;
return ans;
}
};
info lazy[4 * MAX_N];
void propag( int v, int l, int r ) {
if ( l != r ) {
lazy[v * 2 + 1] = lazy[v * 2 + 1] + lazy[v];
lazy[v * 2 + 2] = lazy[v * 2 + 2] + lazy[v];
lazy[v] = { 0, 0 };
}
}
void update( int v, int l, int r, int lu, int ru, int x ) {
propag( v, l, r );
if ( l > ru || r < lu )
return;
if ( lu <= l && r <= ru ) {
info add = { x, min( x, 0LL ) };
lazy[v] = lazy[v] + add;
propag( v, l, r );
return;
}
int mid = (l + r) / 2;
update( v * 2 + 1, l, mid, lu, ru, x );
update( v * 2 + 2, mid + 1, r, lu, ru, x );
}
long long query( int v, int l, int r, int p ) {
propag( v, l, r );
if ( l == r )
return lazy[v].sum - lazy[v].minn;
int mid = (l + r) / 2;
if ( p <= mid )
return query( v * 2 + 1, l, mid, p );
return query( v * 2 + 2, mid + 1, r, p );
}
} qs;
signed main() {
int n, m, q;
cin >> n >> m >> q;
while ( q-- ) {
int type;
cin >> type;
if ( type == 1 ) {
int l, r, c, k;
cin >> l >> r >> c >> k;
qs.update( 0, 1, n, l, r, k );
} else if ( type == 2 ) {
int l, r, k;
cin >> l >> r >> k;
qs.update( 0, 1, n, l, r, -k );
} else {
int p;
long long x;
cin >> p >> x;
long long s = qs.query( 0, 1, n, p );
cout << (s >= x) << "\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
91 ms |
2508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
414 ms |
8652 KB |
Output is correct |
2 |
Correct |
343 ms |
12884 KB |
Output is correct |
3 |
Correct |
461 ms |
14532 KB |
Output is correct |
4 |
Correct |
307 ms |
13112 KB |
Output is correct |
5 |
Correct |
329 ms |
13136 KB |
Output is correct |
6 |
Correct |
439 ms |
14844 KB |
Output is correct |
7 |
Correct |
252 ms |
4692 KB |
Output is correct |
8 |
Correct |
259 ms |
4832 KB |
Output is correct |
9 |
Correct |
435 ms |
14928 KB |
Output is correct |
10 |
Correct |
506 ms |
14776 KB |
Output is correct |
11 |
Correct |
393 ms |
14840 KB |
Output is correct |
12 |
Correct |
439 ms |
14648 KB |
Output is correct |
13 |
Correct |
412 ms |
15088 KB |
Output is correct |
14 |
Correct |
427 ms |
14636 KB |
Output is correct |
15 |
Correct |
446 ms |
14824 KB |
Output is correct |
16 |
Correct |
434 ms |
14636 KB |
Output is correct |
17 |
Correct |
433 ms |
14676 KB |
Output is correct |
18 |
Correct |
454 ms |
14756 KB |
Output is correct |
19 |
Correct |
493 ms |
14768 KB |
Output is correct |
20 |
Correct |
490 ms |
14804 KB |
Output is correct |
21 |
Correct |
418 ms |
14788 KB |
Output is correct |
22 |
Correct |
438 ms |
14688 KB |
Output is correct |
23 |
Correct |
435 ms |
14932 KB |
Output is correct |
24 |
Correct |
451 ms |
14732 KB |
Output is correct |
25 |
Correct |
418 ms |
14156 KB |
Output is correct |
26 |
Correct |
412 ms |
14416 KB |
Output is correct |
27 |
Correct |
375 ms |
14496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
101 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |