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 ...
随机推荐
- 关于百度地图API和jqGrid踩到的坑
1.百度地图重新标记问题 var map = new BMap.Map("map"); ...... var marker = new BMap.Marker(point); // ...
- React-Native之轮播组件looped-carousel的介绍与使用
React-Native之轮播组件looped-carousel的介绍与使用 一,关于react-native轮播组件的介绍与对比 1,react-native-swiper在动态使用网页图片,多张图 ...
- Bootstrap知识记录:表单和图片
一.表单Bootstrap 提供了一些丰富的表单样式供开发者使用.1.基本格式//实现基本的表单样式<form><div class="form-group"&g ...
- Oracle 修改数据库表数据提交之后进行回滚
--查看历史数据 select * from test1 as of timestamp to_timestamp('2018-12-23 14:41:00', 'yyyy-mm-dd hh24:mi ...
- C# Note4:XML序列化和反序列化(含加密解密等)
前言 在项目中,我们经常用到各种配置文件,比如xml文件.binary文件等等,这里主要根据实践经验介绍下xml文件的序列化和反序列化(毕竟最常用). 实践背景:我要做一个用户管理功能,用户账号信息存 ...
- python学习笔记(12)--程序设计方法学
计算思维: 逻辑思维:推演和演绎 实证思维:实验和验证,引力波->实验 计算思维:设计和构造,计算机为代表,汉诺塔递归. 计算思维特征 抽象和自动化,抽象问题的计算过程,利用计算机自动化求解. ...
- ERP行业内幕看了这五个问题全懂了
ERP系统是现代企业实现信息化管理的必经之路.但很多管理人员或已经在用ERP的人员,其实并不太懂ERP系统是什么意思,有哪些好处等,导致实际使用过程中经常大材小用,或者“英雄无用武之地”.所以,为了更 ...
- flask Django保存session区别
'''Django中,session保存在服务端的数据库中,数据库中保存请求用户的所有数据,服务端数据中{'随机字符串':加密后的客户相关信息}请求完成后,把随机字符串作为值,返回给客户端,保存在客户 ...
- PHP关联查询
article文章表: aid title content uid 1 文章1 文章1正文内容... 1 2 文章2 文章2正文内容... 1 3 文章3 文章3正文内容... 2 4 文章4 文章4 ...
- react用class关键字来创建组件
创建组件之前,首先学习一个ES6的写法,叫做展开运算符. 比如我这里有两个数组.如何将第二个数组o2中的所有属性导入到数组o1中呢?一个个输太麻烦,所以就用到了展开运算符. var o2={ age: ...