This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h> // pA
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define debug(x) cerr << #x << " = " << (x) << ' '
#define endl cerr << '\n'
#define all(v) (v).begin(), (v).end()
#define SZ(v) (ll)(v).size()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const int N = 3e5+5;
//const int INF = 2e9;
ll Seg[N<<2], laz[N<<2];
inline void push(ll v, ll L, ll R)
{
Seg[v] = max(Seg[v]+laz[v], 0LL);
if (L == R) return;
laz[v<<1] += laz[v], laz[v<<1|1] += laz[v];
laz[v] = 0;
}
inline void modify(ll L, ll R, ll ql, ll qr, ll v, ll val)
{
push(v, L, R);
if (L <= ql && qr <= R)
{
laz[v] += val;
return;
}
int mid((L+R)>>1);
if (qr <= mid) modify(L, mid, ql, qr, v<<1, val);
else if (ql > mid) modify(mid+1, R, ql, qr, v<<1|1, val);
else {
modify(L, mid, ql, mid, v<<1, val);
modify(mid+1, R, mid+1, qr, v<<1|1, val);
}
}
inline ll query(ll L, ll R, ll v, ll pos)
{
push(v, L, R);
if (L == R) return Seg[v];
int mid((L+R)>>1);
if (pos <= mid) return query(L, mid, v<<1, pos);
return query(mid+1, R, v<<1|1, pos);
}
int main(void)
{ IO
ll n, m, Q, t, L, R, c, k, tmp;
cin >> n >> m >> Q;
if (m != 1) assert(0);
do {
cin >> t;
if (t == 1)
{
cin >> L >> R >> c >> k;
modify(1, n, L, R, 1, k);
} else if (t == 2) {
cin >> L >> R >> k;
modify(1, n, L, R, 1, -k);
} else {
cin >> L >> k;
tmp = query(1, n, 1, L);
if (tmp >= k) cout << "1\n";
else cout << "0\n";
}
} while (--Q);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |