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 ...
随机推荐
- 教你玩转产品管理系统iClap(基础功能篇)
距iClap这款宇宙级产品的推出已经有一段时间了,相信不少小伙伴们都已经开始使用上了,多好用多方便,就不用说了,可不想违反广告法呢!不过还是有用户反映说某些功能不太了解,或者还有一些不清楚的操作方式, ...
- 解读jquery.filtertable.min
jQuery.FilterTable是一款表格搜索过滤和单元格高亮插件. 该插件允许你对任意表格进行条件过滤,并且它会将搜索到的结果单元格高亮显示,非常实用和强大. 使用方法在页面中引入jquery和 ...
- Root :: AOAPC I: Beginning Algorithm Contests (Rujia Liu) Volume 7. Graph Algorithms and Implementation Techniques
uva 10803 计算从任何一个点到图中的另一个点经历的途中必须每隔10千米 都必须有一个点然后就这样 floy 及解决了 ************************************* ...
- 【转】eclipse反编译插件
原文地址:http://bbs.csdn.net/topics/390263414 离线安装包下载地址一:http://feeling.sourceforge.net/downloads/org.sf ...
- PowerDesigner 教程
摘自:http://www.cnblogs.com/advocate/p/3730027.html 目标:本文主要介绍PowerDesigner中概念数据模型 CDM的基本概念. 一.概念数据模型概述 ...
- Python入门之实现简单的购物车功能
Talk is cheap,Let's do this! product_list = [ ['Iphone7 Plus', 6500], ['Iphone8 ', 8200], ['MacBook ...
- 20145101《Java程序设计》第三周学习总结
20145101 <Java程序设计>第3周学习总结 教材学习内容总结 本周进行的是第四章和第五章的学习.本阶段的学习难度有所提升,无论是在知识的量还是深度都开始增加,内容很丰富,也很有趣 ...
- 20145301赵嘉鑫 《网络对抗》Exp9 Web安全基础实践
20145301赵嘉鑫 <网络对抗>Exp9 Web安全基础实践 实验后回答问题 (1)SQL注入攻击原理,如何防御 SQL注入攻击原理:SQL 是一门 ANSI 的标准计算机语言,用来访 ...
- noip2015 day1
不解释,很简单,直接按照题目的方法构造就行了 Code #include<iostream> #include<cstdio> #include<cctype> # ...
- Python数据分析入门之pandas基础总结
Pandas--"大熊猫"基础 Series Series: pandas的长枪(数据表中的一列或一行,观测向量,一维数组...) Series1 = pd.Series(np.r ...