#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define COMPRESS(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin())
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<ld> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };
Pll lazy[524288];
ll tree[524288];
void g(Pll &p1,Pll p2){
if(p1.Y<=p2.X){
p1.X+=p2.X-p1.Y;
p1.Y=p2.Y;
}else{
p1.Y+=p2.Y-p2.X;
}
}
void propagation(int node,int S,int E){
tree[node]=max(tree[node]-lazy[node].X,0ll)+lazy[node].Y;
if(S!=E){
int L=node<<1,R=L|1;
g(lazy[L],lazy[node]);
g(lazy[R],lazy[node]);
}
lazy[node]=mp(0,0);
}
void upd(int node,int S,int E,int i,int j,ll k){
propagation(node,S,E);
if (i>E || j<S)return;
if(i<=S && E<=j){
if(k>0)lazy[node].Y+=k;
else lazy[node].X-=k;
propagation(node,S,E);
return;
}
upd(node<<1,S,(S+E)/2,i,j,k);
upd(node<<1|1,(S+E)/2+1,E,i,j,k);
}
ll find(int node,int S,int E,int i,int j){
propagation(node,S,E);
if (i>E || j<S)return 0;
if(i<=S && E<=j)return tree[node];
return find(node<<1,S,(S+E)/2,i,j)+find(node<<1|1,(S+E)/2+1,E,i,j);
}
int main(){
int n,m,q;
scanf("%d%d%d",&n,&m,&q);
while(q--){
int t;
scanf("%d",&t);
if(t==1){
int l,r,c;
ll k;
scanf("%d%d%d%lld",&l,&r,&c,&k);
upd(1,1,n,l,r,k);
}else if(t==2){
int l,r;
ll k;
scanf("%d%d%lld",&l,&r,&k);
upd(1,1,n,l,r,-k);
}else{
int a;
ll b;
scanf("%d%lld",&a,&b);
if(find(1,1,n,a,a)>=b)puts("1");
else puts("0");
}
}
}
Compilation message
foodcourt.cpp: In function 'int main()':
foodcourt.cpp:82:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
82 | scanf("%d%d%d",&n,&m,&q);
| ~~~~~^~~~~~~~~~~~~~~~~~~
foodcourt.cpp:85:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
85 | scanf("%d",&t);
| ~~~~~^~~~~~~~~
foodcourt.cpp:89:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
89 | scanf("%d%d%d%lld",&l,&r,&c,&k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:94:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
94 | scanf("%d%d%lld",&l,&r,&k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:99:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
99 | scanf("%d%lld",&a,&b);
| ~~~~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
74 ms |
3400 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
480 ms |
12796 KB |
Output is correct |
2 |
Correct |
357 ms |
16896 KB |
Output is correct |
3 |
Correct |
506 ms |
18592 KB |
Output is correct |
4 |
Correct |
434 ms |
17092 KB |
Output is correct |
5 |
Correct |
394 ms |
17124 KB |
Output is correct |
6 |
Correct |
536 ms |
18860 KB |
Output is correct |
7 |
Correct |
110 ms |
4508 KB |
Output is correct |
8 |
Correct |
113 ms |
4400 KB |
Output is correct |
9 |
Correct |
510 ms |
18788 KB |
Output is correct |
10 |
Correct |
513 ms |
18804 KB |
Output is correct |
11 |
Correct |
555 ms |
18756 KB |
Output is correct |
12 |
Correct |
575 ms |
18824 KB |
Output is correct |
13 |
Correct |
545 ms |
18864 KB |
Output is correct |
14 |
Correct |
568 ms |
18748 KB |
Output is correct |
15 |
Correct |
601 ms |
18764 KB |
Output is correct |
16 |
Correct |
625 ms |
18732 KB |
Output is correct |
17 |
Correct |
550 ms |
18600 KB |
Output is correct |
18 |
Correct |
567 ms |
18816 KB |
Output is correct |
19 |
Correct |
561 ms |
18784 KB |
Output is correct |
20 |
Correct |
556 ms |
18844 KB |
Output is correct |
21 |
Correct |
525 ms |
18692 KB |
Output is correct |
22 |
Correct |
558 ms |
18628 KB |
Output is correct |
23 |
Correct |
577 ms |
18788 KB |
Output is correct |
24 |
Correct |
637 ms |
18824 KB |
Output is correct |
25 |
Correct |
405 ms |
18248 KB |
Output is correct |
26 |
Correct |
410 ms |
18352 KB |
Output is correct |
27 |
Correct |
383 ms |
18372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
87 ms |
3404 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |