/* In the name of GOD */
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mk make_pair
typedef long long ll;
typedef long double ld;
typedef pair <long long, long long> pii;
const int N = 250012, SegN = (1 << 18);
const long long INF = 1e16 + 31;
pii lz[SegN];
ll t[N], l[N], r[N], c[N], x[N];
ll k[N];
void shift (int v) {
ll x = lz[v].F, y = lz[v].S;
lz[v << 1].F += x;
lz[v << 1].S += x;
lz[v << 1 | 1].F += x;
lz[v << 1 | 1].S += x;
lz[v << 1].S = max(lz[v << 1].S, y);
lz[v << 1 | 1].S = max(lz[v << 1 | 1].S, y);
lz[v] = mk(0, -INF);
}
void mx (int l, int r, ll x, int v = 1, int tl = 0, int tr = N - 1) {
if (tl > r || l > tr)
return;
if (l <= tl && tr <= r) {
lz[v].S = max(lz[v].S, x);
} else {
shift(v);
int mid = (tl + tr) >> 1;
mx (l, r, x, v << 1, tl, mid);
mx (l, r, x, v << 1 | 1, mid + 1, tr);
}
}
void add (int l, int r, ll x, int v = 1, int tl = 0, int tr = N - 1) {
// cout << l << ' ' << r << ' ' << x << ' ' << v << ' ' << tl << ' ' << tr << '\n';
if (tl > r || l > tr)
return;
if (l <= tl && tr <= r) {
//cout << "wef\n";
lz[v].S += x;
lz[v].F += x;
//cout << lz[v].F << ' ' << lz[v].S << '\n';
} else {
shift(v);
int mid = (tl + tr) >> 1;
add (l, r, x, v << 1, tl, mid);
add (l, r, x, v << 1 | 1, mid + 1, tr);
}
}
pii get (int i, int v = 1, int tl = 0, int tr = N - 1) {
if (tl == tr)
return lz[v];
shift(v);
int mid = (tl + tr) >> 1;
if (i <= mid)
return get (i, v << 1, tl, mid);
return get (i, v << 1 | 1, mid + 1, tr);
}
int32_t main () {
ios::sync_with_stdio(false);
cin.tie();
for (int v = 0; v < SegN; v++)
lz[v] = mk(0, -INF);
int n, m, q;
cin >> n >> m >> q;
for (int i = 0; i < q; i++) {
cin >> t[i];
if (t[i] == 1) {
cin >> l[i] >> r[i] >> c[i] >> k[i];
add (l[i], r[i], k[i]);
} else if (t[i] == 2) {
cin >> l[i] >> r[i] >> k[i];
add (l[i], r[i], -k[i]);
mx (l[i], r[i], 0);
} else {
cin >> l[i] >> k[i];
pii p = get (l[i]);
cout << (max(p.F, p.S) >= k[i]) << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
8796 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
8796 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
8788 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
8788 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
8796 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
8800 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
8796 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
8796 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |