用一个三维数组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的更多相关文章

  1. 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 ...

  2. CodeForces 835C - Star sky | Codeforces Round #427 (Div. 2)

    s <= c是最骚的,数组在那一维开了10,第八组样例直接爆了- - /* CodeForces 835C - Star sky [ 前缀和,容斥 ] | Codeforces Round #4 ...

  3. 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 ...

  4. 动态规划:Codeforces Round #427 (Div. 2) C Star sky

    C. Star sky time limit per test2 seconds memory limit per test256 megabytes inputstandard input outp ...

  5. Star sky 二维前缀和

    C. Star sky time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...

  6. Codeforces 835C - Star sky - [二维前缀和]

    题目链接:http://codeforces.com/problemset/problem/835/C 题意: 在天空上划定一个直角坐标系,有 $n$ 颗星星,每颗星星都有坐标 $(x_i,y_i)$ ...

  7. 【Codeforces Round #427 (Div. 2) C】Star sky

    [Link]:http://codeforces.com/contest/835/problem/C [Description] 给你n个星星的坐标(xi,yi); 第i个星星在第t秒,闪烁值变为(s ...

  8. C. Star sky 二维前缀和

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  9. CF Round #427 (Div. 2) C. Star sky [dp]

    题目链接就长这样子? time limit per test 2 seconds memory limit per test 256 megabytes   Description The Carte ...

随机推荐

  1. jmeter的jtl日志转html报告常见报错笔记

    问题:生成的jmeter文件可以放任意位置 输入命令转换hmtl报告 PS D:\user\80003288\桌面\Ques> jmeter -g .\test1.jtl -e -o .\rep ...

  2. 字符串和ASCII之间的转换

    public class CharToAscii { public static void main(String[] args) { CharToAscii.AscToString(); CharT ...

  3. Day 5-<补充> 类的的继承和查找顺序

    类的继承于查找顺序: 在py2中,不继承object的类为经典类,经典类继承查找:深度优先. 在py3中,默认继承object,所以python3中都是新式类,新式类的继承查找:广度优先. 类的特殊属 ...

  4. java日志框架之logback(一)——logback工程简介

    Logback工程 致力于成为log4j工程的继承者 Logback的架构足够泛型化,故能够应用于许多不同的环境.当前,logback划分为三个组件: logback-core logback-cla ...

  5. Django Rest framework 框架

    一.开发模式: 1. 普通开发方式(前后端放在一起写) 2. 前后端分离(前后台通过ajaxo交互) 后端(django rest framework写的) <----ajaxo---> ...

  6. python爬虫之scrapy安装(一)

    简介: Scrapy,Python开发的一个快速.高层次的屏幕抓取和web抓取框架,用于抓取web站点并从页面中提取结构化的数据.Scrapy用途广泛,可以用于数据挖掘.监测和自动化测试. Scrap ...

  7. DAY05、基本数据类型与内置方法

    一.可变类型与不可变类型: 1.可变类型:值改变,但是id不变 2.不可变类型:值改变,id也改变 二.数据类型: 1.数字类型: 1.1:整型int: 用途:记录年龄.等级.数量 定义方式:age ...

  8. 三、checkedListBoxControl

    一.checkedListBoxControl的使用全选 private void InitDate() { CheckedListBoxItem[] itemArr = { new CheckedL ...

  9. Scss - 简单笔记

    原文链接:scss 教程 手头上疯狂在用 scss,虽然可以在里面写原生的 css, 但是为了保持风格的一致性,还是滚去看了看 scss 文档. 一.变量 变量的引入是 scss 的一个核心特性,变量 ...

  10. EChart.js 笔记一

    一直对数据可视化比较感兴趣,当年 Alibaba 年报晚会上的大屏显示可谓是技惊四座,够震撼,将数据之美展现得淋漓尽致. 国内的前端数据可视化插件中,echart.js 算是热度很高的,也容易上手,算 ...