Star sky CodeForces - 835C
用一个三维数组cnt[x][y][k]表示从(1, 1)到(x, y)亮度为k的个数,然后查询的时候就是对于每一个亮度,计算出这个亮度t秒后的亮度和当前这个亮度的个数,答案就是他们的乘积, 然后遍历每种亮度就可以算出答案
#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<stack>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lowbit(x) (x & (-x)) typedef unsigned long long int ull;
typedef long long int ll;
const double pi = 4.0*atan(1.0);
const int inf = 0x3f3f3f3f;
const int maxn = ;
const int maxm = ;
const int mod = 1e9+;
using namespace std; int n, m;
int T, tol;
int cnt[maxn][maxn][maxn/]; void init() {
memset(cnt, , sizeof cnt);
} int main() {
init();
int q, c;
scanf("%d%d%d", &n, &q, &c);
int mx=, my=;
int x, y, s;
for(int i=; i<=n; i++) {
scanf("%d%d%d", &x, &y, &s);
cnt[x][y][s]++;
mx = max(mx, x);
my = max(my, y);
}
for(int i=; i<=; i++) {
for(int j=; j<=; j++) {
for(int k=; k<=c; k++) {
cnt[i][j][k] = cnt[i][j][k] + cnt[i-][j][k] + cnt[i][j-][k] - cnt[i-][j-][k];
}
}
}
int t, x1, y1, x2, y2;
while(q--) {
scanf("%d%d%d%d%d", &t, &x1, &y1, &x2, &y2);
int ans = ;
for(int k=; k<=c; k++) {
int tmp = (k+t) % (c+);
int cx = cnt[x2][y2][k] - cnt[x1-][y2][k] - cnt[x2][y1-][k] + cnt[x1-][y1-][k];
ans += tmp * cx;
}
printf("%d\n", ans);
}
return ;
}
Star sky CodeForces - 835C的更多相关文章
- 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 ...
- CodeForces 835C - Star sky | Codeforces Round #427 (Div. 2)
s <= c是最骚的,数组在那一维开了10,第八组样例直接爆了- - /* CodeForces 835C - Star sky [ 前缀和,容斥 ] | Codeforces Round #4 ...
- 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 ...
- 动态规划:Codeforces Round #427 (Div. 2) C Star sky
C. Star sky time limit per test2 seconds memory limit per test256 megabytes inputstandard input outp ...
- Star sky 二维前缀和
C. Star sky time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...
- Codeforces 835C - Star sky - [二维前缀和]
题目链接:http://codeforces.com/problemset/problem/835/C 题意: 在天空上划定一个直角坐标系,有 $n$ 颗星星,每颗星星都有坐标 $(x_i,y_i)$ ...
- 【Codeforces Round #427 (Div. 2) C】Star sky
[Link]:http://codeforces.com/contest/835/problem/C [Description] 给你n个星星的坐标(xi,yi); 第i个星星在第t秒,闪烁值变为(s ...
- 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 ...
随机推荐
- jvisualvm远程监控 visualgc插件 不受此jvm支持问题
https://yq.aliyun.com/ziliao/478212 1.修改远程服务器上java设置 vi $JAVA_HOME/jre/lib/security/java.policy 在 ...
- 1170 - BLOB/TEXT column 'CustomerName' used in key specification without a key length
[DTF] Data Transfer 企管宝_2_CRM start[DTF] Getting tables[DTF] Analyzing table: `CustomerInfo`[DTF] Ge ...
- css特殊样式
span{ color: blue; border:1px solid black;}.extra span{ color: inherit;} 清除原有样式 text-decoration: non ...
- Junit概述
Junit -> java unit.也就是说Junit是xunit家族中的一员. unit <- unit test case,即单元测试用例. Junit = java uni ...
- centos安装Tesseract
yum安装(推荐) yum search tesseract yum install tesseract.x86_64 -y pip3 install pytesseract pip3 install ...
- Visual Studio2012调试时无法命中断点
今天在调试代码的时候发现在Debug模式下无法命中断点,然后一步步去检查原因,最后发现是在项目-->属性-->生成-->高级-->调试信息被设置为None,然后在选项中将其选择 ...
- ajax查看详细返回信息
查看详细成功返回信息: success : function(data, textStatus, jqXHR) { console.log(data); console.log(textStatus) ...
- SpringBoot之加载自定义配置文件
SpringBoot默认加载配置文件名为:application.properties和application.yml,如果需要使用自定义的配置文件,则通过@PropertySource注解指定. J ...
- js中的异常处理
js中的异常处理语句有两个,一个是try……catch……,一个是throw. try……catch用于语法错误,错误有name和message两个属性.throw用于逻辑错误. 对于逻辑错误,js是 ...
- Jira的搭建
一.环境准备 jira7.2的运行是依赖java环境的,也就是说需要安装jdk并且要是1.8以上版本,如下: java -version 除此之外,我们还需要为jira创建对应的数据库.用户名和密码, ...