Submission #882198

#TimeUsernameProblemLanguageResultExecution timeMemory
882198RegulusFood Court (JOI21_foodcourt)C++17
0 / 100
117 ms8928 KiB
#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) 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 (ql <= L && R <= qr) { 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"; } //for (int i=1; i <= n; ++i) cerr << query(1, n, 1, i) << ' '; endl; } while (--Q); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...