I can’t figure out what’s wrong in the code.
Problem: Problem - C - Codeforces
Code:
int n,q,c;
int light[101][101][11];// x y t
int sum[101][101][11];// x y t
int mp[101][101];
signed main(){
FASTER;
cin>>n>>q>>c;
for(int i=0;i<n;i++){
int x,y,s;cin>>x>>y>>s;
light[x][y][0]=s;
mp[x][y]=1;
}
for(int x=1;x<=100;x++){
for(int y=1;y<=100;y++){
for(int t=1;t<=10;t++){
if(mp[x][y]){
light[x][y][t]=light[x][y][t-1]+1;
if(light[x][y][t]>c)light[x][y][t]=0;
}
}
}
}
//base case
for(int x=1;x<=100;x++){
for(int t=0;t<=10;t++){
sum[x][1][t]=sum[x-1][1][t]+light[x][1][t];
sum[1][x][t]=sum[1][x-1][t]+light[1][x][t];
}
}
for(int x=2;x<=100;x++){
for(int y=2;y<=100;y++){
for(int t=0;t<=10;t++){
sum[x][y][t]=sum[x-1][y][t]+sum[x][y-1][t]-sum[x-1][y-1][t]+light[x][y][t];
}
}
}
for(int i=0;i<q;i++){
int t,x,y,x2,y2;cin>>t>>x2>>y2>>x>>y;
t%=(c+1);
cout<<sum[x][y][t]+sum[x2-1][y2-1][t]-sum[x2][y-1][t]-sum[x-1][y2][t]<<"\n";
}
}
Thanks!
Edit1: So I wasn’t consider the fact that there can be multiple stars at a single point. But let’s say that there can’t be multiple stars on a point, and I am still getting WA…