Codefores 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的更多相关文章
- CodeForces 835C - Star sky | Codeforces Round #427 (Div. 2)
s <= c是最骚的,数组在那一维开了10,第八组样例直接爆了- - /* CodeForces 835C - Star sky [ 前缀和,容斥 ] | Codeforces Round #4 ...
- Codeforces 835C - Star sky - [二维前缀和]
题目链接:http://codeforces.com/problemset/problem/835/C 题意: 在天空上划定一个直角坐标系,有 $n$ 颗星星,每颗星星都有坐标 $(x_i,y_i)$ ...
- 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 ...
- Star sky 二维前缀和
C. Star sky time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...
- 动态规划:Codeforces Round #427 (Div. 2) C Star sky
C. Star sky time limit per test2 seconds memory limit per test256 megabytes inputstandard input outp ...
- 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 ...
- Star sky CodeForces - 835C
用一个三维数组cnt[x][y][k]表示从(1, 1)到(x, y)亮度为k的个数,然后查询的时候就是对于每一个亮度,计算出这个亮度t秒后的亮度和当前这个亮度的个数,答案就是他们的乘积, 然后遍历每 ...
- C. Star sky 二维前缀和
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- CF Round #427 (Div. 2) C. Star sky [dp]
题目链接就长这样子? time limit per test 2 seconds memory limit per test 256 megabytes Description The Carte ...
- 【Codeforces Round #427 (Div. 2) C】Star sky
[Link]:http://codeforces.com/contest/835/problem/C [Description] 给你n个星星的坐标(xi,yi); 第i个星星在第t秒,闪烁值变为(s ...
随机推荐
- mysql数据库给别人访问权限
注:本操作是在WIN命令提示符下,phpMyAdmin同样适用. 用户:phplamp 用户数据库:phplampDB 1.新建用户. //登录MYSQL @>mysql -u root -p ...
- VUE路由去除#问题
最近自己在写一个vue的小型管理系统,在浏览器中看到的路由都是带有#的,很是不好看.为了解决此问题,大家一般都会想到:mode: 'history'.可是在开发阶段没有问题,但是一旦build打包后, ...
- liferay中如何获取实例的id和portletId
在Portlet中request分为两种renderRequet和actionRequest而portlet需要取得实例Id的时候都在renderRequest的时候才可以取到,如下例子 Portle ...
- 文件操作(CRT、C++、WIN API、MFC)
一.使用CRT函数文件操作 二.使用标准C++库 std::fstream std::string 1)std::string对象内部存储了一个C的字符串,以'\0'结尾的. 2)std::strin ...
- requirejs初体验
1.引入requirejs <script type="text/javascript" src="/js/common/require2.3.5.js" ...
- eclipse工具maven项目打包文件不是最新修改的
1.问题描述:maven项目,完成一些功能开发后,在进行打包更新服务器系统时,本地eclipse工具对文件打成jar包操作,更新到服务器上没有修改的效果,包括打包整个工程为一个war包,也是有同样问题 ...
- Linux基础命令---ziinfo
zipinfo 在不解压的情况下,获取zip压缩文件的的详细信息.zipinfo列出了ZIP档案中有关文件的技术信息,最常见的是在MS-DOS系统上.这些信息包括文件访问权限.加密状态.压缩类型.版本 ...
- linux基础命令---chattr
chattr 改变文件的属性,这个命令只有超级用户才能使用.这个指令适用于ext2.ext3.ext4.xfs.ubifs.reiserfs.jfs系统. 此命令的适用范围:RedHat.RHEL.U ...
- 有趣的js匿名函数写法(function嵌套)
例子没有什么实际意义,只能做为思路参考 <!DOCTYPE html> <html> <head> <meta charset="UTF-8&quo ...
- 作为从业人员,如果一定要学一门新的编程语言,那么它一定是c++
作为从业人员,如果一定要学一门新的编程语言,那么它一定是c++. 无论各种编程语言排行榜如何变化,什么语言最赚钱,想成为真正的程序员,那么c/c++是必修课,因为几乎所有的底层都是c/c++编写的,各 ...