Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long long m,n,q,x,y,k;
- cin>>m>>n>>q;
- for(long long i = 0;i<q;++i){
- cin>>x>>y>>k;
- long long y1,x1,x2,sum;
- sum = 0;
- for(long long j =0;j<=k;++j){
- y1 = y + k - j;
- x1 = max(x - j,(long long)0);
- x2 = min(x + j, m);
- if(y1>n || y1<0) {
- continue;
- }
- //cout<<y1<<" "<<x1<<" "<<x2<<endl;
- sum += x2 - x1 +1;
- }
- for(long long j =1;j<=k;++j){
- y1 = y - j;
- x1 = max(x - k + j,(long long)0);
- x2 = min(x + k - j, m);
- if(y1>n || y1<0) {
- continue;
- }
- sum += x2 - x1 +1;
- //cout<<y1<<" "<<x1<<" "<<x2<<endl;
- }
- cout<<sum<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement