用一个三维数组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. 解决scrapy报错:ModuleNotFoundError: No module named 'win32api'

    ModuleNotFoundError: No module named 'win32api' 表示win32api未安装 解决办法: 下载对应python版本的win32api,并安装. 下载地址: ...

  2. 使用jmeter来发送json/gzip格式数据 --------笔记

    一.使用jmeter来发送gzip数据 有时候我们需要模拟在客户端将数据压缩后, 发送(post)到服务器端. 通常这种情况,会发生在移动终端上. 这样做的好处, 是可以节省流量.  当然, 服务器返 ...

  3. [转帖]linux 清空history以及记录原理

    linux 清空history以及记录原理 自己的linux 里面总是一堆 乱七八槽输错的命令 用这个办法 可以清空 linux的内容. 清爽一些. 1.当前session执行的命令,放置缓存中,执行 ...

  4. 用户认证--------------auth模块

    一.auth模块 from django.contrib import auth 1 .authenticate()   :验证用户输入的用户名和密码是否相同 提供了用户认证,即验证用户名以及密码是否 ...

  5. Python创建virtualenv(虚拟环境)方法

    本文目录 一 前言 二 通过virtualenv软件创建 三 在pycharm下创建 新建项目 四 已有项目使用和创建虚拟环境 五 参数说明 一 前言 需求:        --公司之有一台服务器   ...

  6. Django的模板层

    一 模版简介 你可能已经注意到我们在例子视图中返回文本的方式有点特别. 也就是说,HTML被直接硬编码在 Python代码之中. def current_datetime(request): now ...

  7. 虚拟机的ip地址为什么会发生变化

    因为虚拟机在NAT模式下由Vmware8虚拟网卡提供虚拟机的IP分配,网桥模式下由Vmware1来提供IP分配.它们都相当于 一个小型的DHCP服务器,除非改动虚拟机的网络连接方式,或动了虚拟网卡服务 ...

  8. 排查 Maxwell can not find database 并且使用 MySQL binlog 解决相关问题

    目前我们在使用 Maxwell 在读线上机器的 binlog 同步我们的离线数据库. 这次错误定位上,首先线要确定问题是发生在生产者 还是队列 还是消费者.经过查看各机器上任务的运行日志,定位到了问题 ...

  9. 莫烦sklearn学习自修第九天【过拟合问题处理】

    1. 过拟合问题可以通过调整机器学习的参数来完成,比如sklearn中通过调节gamma参数,将训练损失和测试损失降到最低 2. 代码实现(显示gamma参数对训练损失和测试损失的影响) from _ ...

  10. 我的Git

    1.git 的安装与配置. 首先,对git进行下载.然后,在本地安装后进行版本查看,win10系统通过win+r快捷键打开控制台,然后用git --version的cmd命令查看git版本. 然后对g ...