https://i2.wp.com/eblogarithm.com/wp-content/uploads/2017/08/Codeforces-Round-427-Div-2-problem-C-Star-sky-Solution-In-CC1.png?fit=640%2C360

Codeforces Round #427 (Div. 2), problem: (C) Star sky Solution In C/C++

#include<iostream>
#include<cstdio>
using namespace std;
int a[201][201][21];
int x,y,x1,y1,s;
int main()
{
int n,q,c;
int i,j,k;

scanf(“%d%d%d”,&n,&q,&c);
for(i=1;i<=n;i++)
{
scanf(“%d%d%d”,&x,&y,&s);
for(j=0;j<=c;j++)
a[x][y][j]+=(s+j)%(c+1);
}
for(i=1;i<=100;i++)
for(j=1;j<=100;j++)
for(k=0;k<=c;k++)
a[i][j][k]+=a[i][j-1][k]+a[i-1][j][k]-a[i-1][j-1][k];
for(i=1;i<=q;i++)
{
scanf(“%d%d%d%d%d”,&s,&x,&y,&x1,&y1);
s%=(c+1);
printf(“%d\n”,a[x1][y1][s]-a[x-1][y1][s]-a[x1][y-1][s]+a[x-1][y-1][s]);
}
}

(Visited 23 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: