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. 使用feof()判断文件结束时会多输出内容的原因

    这是原来的代码: #include <stdio.h>int main(){    FILE * fp;    int ch;    fp = fopen("d:\\aaaaa\ ...

  2. 013-安装VNC服务

    (1)#001-安装#光盘iso文件安装mount /dev/cdrom /mntcd /mnt/Packagesrpm -ivh tigervnc*rpm -ivh tigervnc按两次tab键 ...

  3. Servlet—生命周期

    首次访问 重复访问 换浏览器访问(说明在一次项目运行期间,servlet实例只会创建一个)

  4. 浏览器内核控制标签meta说明

    由于众所周知的原因,国内的主流浏览器都是双核浏览器:基于Webkit的内核用于常用网站的高速浏览,基于IE的内核主要用于部分网银.政府.办公系统等网站的正常使用.以360浏览器为例,我们优先通过Web ...

  5. Linux查看操作系统版本

    Linux版本太多,不同版本的命令又有所区别,所以在解决Linux的一些问题时候无从下手 或者 走一些弯路,这里提供解决此类问题的思路: 查看linux版本号 有了版本号,不同版本 统一问题解决方案不 ...

  6. JProfiler8 远程监控tomcat配置过程

    1. 阅读人群 1.熟悉liunx服务器,起码知道liunx常见的命令 2.熟悉tomcat容器,起码知道怎么tomcat的启动以及停止 3.熟悉java编程语言,JProfiler8是专门监控jav ...

  7. Django框架----数据库表的单表查询

    一.添加表记录 对于单表有两种方式 # 添加数据的两种方式 # 方式一:实例化对象就是一条表记录 Frank_obj = models.Student(name ="海东",cou ...

  8. Django框架----视图函数补充

    视图函数的补充 1.视图函数:一定是要包含两个对象的(render源码里面有HttpResponse对象)   request对象:----->所有的请求信息   HttpResponse:-- ...

  9. java反射之-性能优化

    在最近的计划中,打算看看在不使用google protobuf的情况下,在原有的采用jackson作为json序列化工具的基础上,是否可以实现进一步的性能优化.主要是针对list的情况. 测试的时候选 ...

  10. CF#338D. GCD Table

    传送门 简单的中国剩余定理练习. 首先行数一定是$lcm$,然后只要确定最小的列数就能判定解合不合法了. 我们可以得到线性模方程组: $y \equiv 0 \pmod{a_1}$ $y+1 \equ ...