#define NDEBUG
#ifdef NDEBUG
#define dbg(TXT) (void)0;
#define dbgv(VAR) (void)0;
#define dbgfor if constexpr (false) for
#else
#define _GLIBCXX_DEBUG
#define dbg(TXT) cerr << TXT << "\n";
#define dbgv(VAR) cerr << #VAR << " = " << VAR <<", line "<< __LINE__ << '\n';
#define dbgfor for
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
#define e0 first
#define e1 second
constexpr ll INFTY = 9;//2e18;
struct segtree
{
vector<ll> toadd;
vector<ll> currfloor;
segtree(ll n)
{
toadd.assign(4*n,0);
currfloor.assign(4*n,0);
}
void add(ll val, ll base, ll baseforced, ll lseg, ll rseg, ll l, ll r, ll node)
{
currfloor[node] = max(currfloor[node],baseforced);
if (rseg<l || r<lseg) return;
if (lseg<=l && r<=rseg)
{
toadd[node]+=val;
currfloor[node] = max(currfloor[node],base);
currfloor[node]+=val;
return;
}
ll mid = (l+r)/2;
add(val, base-toadd[node], currfloor[node]-toadd[node], lseg, rseg, l,mid,node*2);
add(val, base-toadd[node], currfloor[node]-toadd[node], lseg, rseg, mid+1,r,node*2+1);
currfloor[node]=-INFTY;
}
ll get(ll x, ll l, ll r, ll node)
{
if (x<l || r<x) return 0;
if (l==r)
{
//if (node==11)dbgv(currfloor[node]);
return currfloor[node];
}
ll mid = (l+r)/2;
ll o =max(toadd[node]+(get(x, l,mid,node*2)+get(x, mid+1,r,node*2+1)),currfloor[node]);
if (o<0 && node==5){
// dbgv(mid+1 << r);
// dbgv(get(x, mid+1,r,node*2+1));
}
return o;
}
};
int main()
{
ll N,M,Q;
cin >> N >> M >> Q;
if (M!=1) throw exception();
segtree stree(N);
dbgfor (ll i=1;i<=N;i++)
{
cerr << stree.get(i, 1,N,1) << " ";
}
dbg("");
for (ll qno = 0; qno < Q; ++qno)
{
ll t;
cin >> t;
if (t==1)
{
ll l,r,c,k;
cin >> l >> r >> c >> k;
stree.add(k,0,-INFTY,l,r, 1,N,1);
}
else if (t==2)
{
ll l,r,k;
cin >> l >> r >> k;
stree.add(-k,k,-INFTY,l,r, 1,N,1);
}
else
{
assert(t==3);
ll a,b;
cin >> a >> b;
if (b<=stree.get(a, 1,N,1))
{
cout << "1\n";
}
else cout << "0\n";
}
dbgv(qno);
dbgfor (ll i=1;i<=N;i++)
{
cerr << stree.get(i, 1,N,1) << " ";
}dbg("");
dbgfor (ll i:stree.toadd)
{
// cerr << i << " ";
}dbg("");
dbgfor (ll i:stree.currfloor)
{
// cerr << i << " ";
}dbg("");
}
}
Compilation message
foodcourt.cpp: In function 'int main()':
foodcourt.cpp:128:14: warning: unused variable 'i' [-Wunused-variable]
128 | dbgfor (ll i:stree.toadd)
| ^
foodcourt.cpp:132:14: warning: unused variable 'i' [-Wunused-variable]
132 | dbgfor (ll i:stree.currfloor)
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
612 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
612 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
378 ms |
19888 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
612 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
604 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
612 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
612 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |