Codeforces 835C Codeforces Round #427 (Div. 2)

星星可以重叠!!!(。。。。)开三维向量存储星星,因为时间以(c+1)循环,三维数组记录不同时刻的不同行前缀和。。。

#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

LL ans[12][105][105];
vector<LL> sky[105][105];
LL n,q,c;
LL x,y,s;
LL t0,x11,y11,x22,y22;


int main()
{
    while(~scanf("%lld%lld%lld",&n,&q,&c))
    {
        memset(ans,0,sizeof(ans));
        for(int i=0;i<101;i++)
        {
            for(int j=0;j<101;j++)
            sky[i][j].clear();
        }
        for(int i=0;i<n;i++)
        {
            scanf("%lld%lld%lld",&x,&y,&s);
            sky[x][y].push_back(s);
        }
        for(int k=0;k<=c;k++)
        for(int i=1;i<=101;i++)
        {
            for(int j=1;j<=101;j++)
            {
                if(sky[i][j].size()>=1)
                {
                    LL pp=0;
                    for(int mm=0;mm<sky[i][j].size();mm++)
                    {
                        if(sky[i][j][mm]==-1) continue;
                        LL xixi=(sky[i][j][mm]+k)%(c+1);
                        pp+=xixi;
                    }
                    ans[k][i][j]=ans[k][i][j-1]+pp;
                }
                else ans[k][i][j]=ans[k][i][j-1];
            }
        //  cout<<ans[k][i][100]<<endl;
        }

        for(int i=0;i<q;i++)
        {
            LL res=0;
            scanf("%lld%lld%lld%lld%lld",&t0,&x11,&y11,&x22,&y22);
            for(int j=x11;j<=x22;j++)
            {
                LL pp=t0%(c+1);
                res+=ans[pp][j][y22]-ans[pp][j][y11-1];
            }
            cout<<res<<endl;
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值