#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
//#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tree<iii, null_type, greater<iii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int N, M, Q, T, L, R, C, K, A;
ll B;
struct node {
node *left, *right;
int pos;
vector<pair<bool, ll> > val;
node(int S, int E) : pos(0) {
if (S == E) return;
int M = (S + E) >> 1;
left = new node(S, M);
right = new node(M + 1, E);
}
void prop(int S, int E) {
if (S == E) return;
for (; pos < val.size(); pos++) {
auto [tmp1, tmp2] = val[pos];
left->val.eb(tmp1, tmp2);
right->val.eb(tmp1, tmp2);
}
}
void upd(int S, int E, int l, int r, int v, bool t = 0) {
if (l > E || r < S) return;
if (l <= S && E <= r) {
val.eb(t, v);
return;
}
prop(S, E);
int M = (S + E) >> 1;
left->upd(S, M, l, r, v, t);
right->upd(M + 1, E, l, r, v, t);
}
ll qry(int S, int E, int p) {
if (S == E) {
ll tmp = 0;
for (; pos < val.size(); pos++) {
auto [tmp1, tmp2] = val[pos];
if (tmp1) tmp = max(0ll, tmp);
else tmp += tmp2;
}
val.eb(0, tmp);
return tmp;
}
int M = (S + E) >> 1;
prop(S, E);
if (p <= M) return left->qry(S, M, p);
else return right->qry(M + 1, E, p);
}
} *root;
main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N >> M >> Q;
root = new node(1, N);
for (int i = 1; i <= Q; i++) {
cin >> T;
if (T == 1) {
cin >> L >> R >> C >> K;
root->upd(1, N, L, R, K);
} else if (T == 2) {
cin >> L >> R >> K;
root->upd(1, N, L, R, -K);
root->upd(1, N, L, R, 0, 1);
} else {
cin >> A >> B;
cout << (root->qry(1, N, A) >= B ? 1 : 0) << '\n';
}
}
}
Compilation message
foodcourt.cpp: In member function 'void node::prop(int, int)':
foodcourt.cpp:43:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<bool, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for (; pos < val.size(); pos++) {
| ~~~~^~~~~~~~~~~~
foodcourt.cpp: In member function 'll node::qry(int, int, int)':
foodcourt.cpp:63:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<bool, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for (; pos < val.size(); pos++) {
| ~~~~^~~~~~~~~~~~
foodcourt.cpp: At global scope:
foodcourt.cpp:78:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
78 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
26692 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
26692 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
466 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
476 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
26692 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
457 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
26692 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
26692 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |