835C-Star sky

思路:dp,预处理一下c+1层前缀和。

代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int INF=0x3f3f3f3f;
const int N=;
int mp[][N][N];
int dp[][N][N]={};
int main()
{
/*ios::sync_with_stdio(false);
cin.tie(0);*/
int n,q,x,y,s,c;
memset(mp,-,sizeof(mp));
scanf("%d%d%d",&n,&q,&c);
for(int i=;i<n;i++)
{
scanf("%d%d%d",&x,&y,&s);
for(int i=;i<c+;i++)
{
dp[i][x][y]+=(s+i)%(c+);//注意同一点有多颗星星的情况
}
}
for(int i=;i<c+;i++)
{
for(int j=;j<=;j++)
{
for(int k=;k<=;k++)
dp[i][j][k]+=dp[i][j-][k]+dp[i][j][k-]-dp[i][j-][k-];//容斥一下
}
}
while(q--)
{
int t,x1,x2,y1,y2;
scanf("%d%d%d%d%d",&t,&x1,&y1,&x2,&y2);
t=t%(c+);
printf("%d\n",dp[t][x2][y2]+dp[t][x1-][y1-]-dp[t][x2][y1-]-dp[t][x1-][y2]);//容斥一下
}
return ;
}

Codefores 835C-Star sky的更多相关文章

  1. CodeForces 835C - Star sky | Codeforces Round #427 (Div. 2)

    s <= c是最骚的,数组在那一维开了10,第八组样例直接爆了- - /* CodeForces 835C - Star sky [ 前缀和,容斥 ] | Codeforces Round #4 ...

  2. Codeforces 835C - Star sky - [二维前缀和]

    题目链接:http://codeforces.com/problemset/problem/835/C 题意: 在天空上划定一个直角坐标系,有 $n$ 颗星星,每颗星星都有坐标 $(x_i,y_i)$ ...

  3. Codeforces Round #427 (Div. 2) [ C. Star sky ] [ D. Palindromic characteristics ] [ E. The penguin's game ]

    本来准备好好打一场的,然而无奈腹痛只能带星号参加 (我才不是怕被打爆呢!) PROBLEM C - Star sky 题 OvO http://codeforces.com/contest/835/p ...

  4. Star sky 二维前缀和

    C. Star sky time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...

  5. 动态规划:Codeforces Round #427 (Div. 2) C Star sky

    C. Star sky time limit per test2 seconds memory limit per test256 megabytes inputstandard input outp ...

  6. Codeforces Round #427 (Div. 2) Problem C Star sky (Codeforces 835C) - 前缀和

    The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinat ...

  7. Star sky CodeForces - 835C

    用一个三维数组cnt[x][y][k]表示从(1, 1)到(x, y)亮度为k的个数,然后查询的时候就是对于每一个亮度,计算出这个亮度t秒后的亮度和当前这个亮度的个数,答案就是他们的乘积, 然后遍历每 ...

  8. C. Star sky 二维前缀和

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  9. CF Round #427 (Div. 2) C. Star sky [dp]

    题目链接就长这样子? time limit per test 2 seconds memory limit per test 256 megabytes   Description The Carte ...

  10. 【Codeforces Round #427 (Div. 2) C】Star sky

    [Link]:http://codeforces.com/contest/835/problem/C [Description] 给你n个星星的坐标(xi,yi); 第i个星星在第t秒,闪烁值变为(s ...

随机推荐

  1. HDU 4500 小Q系列故事——屌丝的逆袭(简单题)

    http://acm.hdu.edu.cn/showproblem.php?pid=4500 AC代码: #include<math.h> #include<stdio.h> ...

  2. linux eaccelerator

    wget https://github.com/eaccelerator/eaccelerator/tarball/master tar -jxvf eaccelerator-0.9.6.1.tar. ...

  3. linux 统计wc

    说明:该命令统计给定文件中的字节数.字数.行数.如果没有给出文件名,则从标准输入读取.wc同时也给出所有指定文件的总统计数.字是由空格字符区分开的最大字符串. 该命令各选项含义如下: - c 统计字节 ...

  4. java opencv使用相关

    Using OpenCV Java with Eclipse http://docs.opencv.org/2.4/doc/tutorials/introduction/java_eclipse/ja ...

  5. 无法在web服务器下启动调试

    VS2013 编译时异常 无法在web服务器下启动调试.该Web服务器未及时响应   VS2013 编译时错误 无法在web服务器上启动调试.该Web服务器未及时响应.无法在web服务器上启动调试.该 ...

  6. python退出多重循环

    假设一段python程序有多重循环,我们都知道在一个循环当中,用break是退出当前的循环,然后继续下一次循环,但是如何才能跳出多重循环呢,实际就是结束所有的循环. 思路1::可以定义一个异常类,在需 ...

  7. 20145316许心远《网络对抗》EXP8 Web基础

    实验后回答问题 什么是表单 来自百度百科的官方定义:表单在网页中主要负责数据采集功能.一个表单有三个基本组成部分: 表单标签:这里面包含了处理表单数据所用CGI程序的URL以及数据提交到服务器的方法. ...

  8. python列表list

    1.通过中括号[ ]括起来,用逗号分隔每个元素,元素可以是数字.字符串.布尔值.列表.元组.字典.集合 2.列表有序(体现在每次打印结果都一样),因此可通过下标索引的方式取元素,下标从0开始,li[m ...

  9. python条件判断if···else、循环while和for

    1.if···else条件判断基本语法 if 条件: 执行语句 elif 条件 : 执行语句 …… else : 执行语句 var=input("请输入表示会员级别的数字(1-5):&quo ...

  10. monit

    Monit 是一个用来监测系统状态的工具,不但可以用来监视进程.服务.文件.目录.文件系统,还可以在服务 down 掉的时候自动重启服务或者当某个进程占用过多的资源的时候自动停掉进程,并且支持 Ema ...