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 ...
随机推荐
- zw版【转发·台湾nvp系列Delphi例程】HALCON SigmaImage1
zw版[转发·台湾nvp系列Delphi例程]HALCON SigmaImage1 procedure TForm1.Button1Click(Sender: TObject);var img, im ...
- Intro to Python for Data Science Learning 3 - functions
Functions from:https://campus.datacamp.com/courses/intro-to-python-for-data-science/chapter-3-functi ...
- tomcat 的最大连接数设置
前提说明为了确保服务不会被过多的http长连接压垮,我们需要对tomcat设定个最大连接数,超过这个连接数的请求会拒绝,让其负载到其它机器.达到保护自己的同时起到连接数负载均衡的作用. 动手去做一开始 ...
- Python: 读文件,写文件
读写文件是最常见的IO操作.Python内置了读写文件的函数. 读写文件前,我们先了解一下,在磁盘上读写文件的功能都是有操作系统提供的,现代操作系统不允许普通的程序直接操作磁盘,所以,读写文件就是请求 ...
- SLF4J和log4j的使用
概念 SLF4J:即简单日志门面(Simple Logging Facade for Java),不是具体的日志解决方案,它只服务于各种各样的日志系统.按照官方的说法,SLF4J是一个用于日志系统的简 ...
- ACM题目————困难的串
题目描述 如果一个字符串包含两个相邻的重复子串,则称他是“容易的串”,其他串称为"困难的串".例如,BB,ABCDACABCAB,ABCDABCD都是容易的串,而D,DC,ABDA ...
- jQuery 中 $( ) 函数的用法总结
摘要 jQuery对象: 具有jquery框架设置的所有功能的调用者, 就是该框架的对象 $又是什么?: $就是jQuery对象, jQuery对象为window的全局属性, 所以可以直接使用 如何自 ...
- JS ——DOM,BOM(包含盒模型,动画)总结
JS盒模型 content: 通过计算后样式获取padding + content: box.clientWidth | box.clientHeightborder + padding + cont ...
- MSM8937系统启动流程【转】
本文转载自:https://blog.csdn.net/chenzhen1080/article/details/54945992?utm_source=blogxgwz8 1 Boot Addres ...
- Wireshark 显示域名列
一般使用Wireshark只能看到ip地址,但是看域名更方便更简明 只要修改一个配置就可以 编辑-->首选项 勾选Resolve network(IP) addresses 重新捕捉: