s <= c是最骚的,数组在那一维开了10,第八组样例直接爆了- -

/*
CodeForces 835C - Star sky [ 前缀和,容斥 ] | Codeforces Round #427 (Div. 2)
题意:
有一片 100*100 的星空,上面有 n 颗星星,每个星星有一个亮度,且在 0~C 范围内周期性变化,现在给出 q 个查询,每个查询给出时间和一个矩形,求在该时间时矩形内星星的亮度和。
c <= 10
分析:
由于 c <= 10,则星星的亮度只有11种情况,全部预处理出来,再求个二维前缀和,查询直接容斥定理
*/
#include <bits/stdc++.h>
using namespace std;
int vis[105][105];
int a[105][105][15];
int n, q, c;
int main()
{
scanf("%d%d%d", &n, &q, &c); c++;
for (int i = 1; i <= n; i++)
{
int x, y, s; scanf("%d%d%d", &x, &y, &s);
for (int t = 0; t < c; t++)
{
a[x][y][t] += s % c;
s = (s+1) % c;
}
vis[x][y] = 1;
}
for (int t = 0; t < c; t++)
{
for (int i = 1; i <= 100; i++)
{
for (int j = 1; j <= 100; j++)
{
a[i][j][t] += a[i][j-1][t];
}
}
for (int j = 1; j <= 100; j++)
{
for (int i = 1; i <= 100; i++)
{
a[i][j][t] += a[i-1][j][t];
}
}
}
while (q--)
{
int t, l, r, h, w;
scanf("%d%d%d%d%d", &t, &h, &l, &w, &r);
t %= c;
int ans = 0;
ans += a[w][r][t];
ans -= a[h-1][r][t] + a[w][l-1][t];
ans += a[h-1][l-1][t];
printf("%d\n", ans);
}
}

  

CodeForces 835C - Star sky | Codeforces Round #427 (Div. 2)的更多相关文章

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

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

  2. CodeForces 835D - Palindromic characteristics | Codeforces Round #427 (Div. 2)

    证明在Tutorial的评论版里 /* CodeForces 835D - Palindromic characteristics [ 分析,DP ] | Codeforces Round #427 ...

  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. Codeforces Round #427 (Div. 2)—A,B,C,D题

    A. Key races 题目链接:http://codeforces.com/contest/835/problem/A 题目意思:两个比赛打字,每个人有两个参数v和t,v秒表示他打每个字需要多久时 ...

  6. Codeforces Round #427 (Div. 2)

    B. The number on the board 题意: 有一个数字,它的每个数位上的数字的和不小于等于k.现在他改变了若干位,变成了一个新的数n,问现在的数和原来的数最多有多少位不同. 思路: ...

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

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

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

  9. Codeforces Round #427 (Div. 2) Problem D Palindromic characteristics (Codeforces 835D) - 记忆化搜索

    Palindromic characteristics of string s with length |s| is a sequence of |s| integers, where k-th nu ...

随机推荐

  1. 快速查看表结构 SQL server查看表注释以及字段注释表结构字段说明

    DECLARE @tableName NVARCHAR(MAX);SET @tableName = N'UserIntegralExchange';   --表名!!! SELECT CASE WHE ...

  2. 1、Ubuntu linux下同步windows火狐foxfire 浏览器收藏夹问题

    最近在ubuntu系统中使用自带的firefox浏览器,发现有一些问题,比如登陆后,书签,历史记录等,原本在windows下同步的数据无法同步,添加书签的功能也无法使用. 经过查询资料后得知,unbu ...

  3. Kubernetes---网络通讯模式笔记

    ⒈kubernetes网络通讯模式     Kubernetes的网络模型假定了所有Pod都在一个可以直接连通的扁平的网络空间中,这在GCE(Google Compute Engine)里面是现成的网 ...

  4. (十三)springMvc 处理 Json

    目录 文章目录 为什么用 Json 处理 json 的流程 环境准备 配置 json 转换器 后记 更新 为什么用 Json Json 格式简单,语法简单,解析简单 : 处理 json 的流程 判断客 ...

  5. springcloud注解

    @EnableEurekaServer:启动一个服务注册中心提供给其他应用进行对话 @EnableZuulProxy:开启网关; @FeignClient:发现服务 @EnableFeignClien ...

  6. 怎么保证 redis 和 db 中的数据一致

    你只要用缓存,就可能会涉及到缓存与数据库双存储双写,你只要是双写,就一定会有数据一致性的问题,那么你如何解决一致性问题? 首先需要考虑到:更新数据库或者更新缓存都有可能失败,在这种前提下分析业务带来的 ...

  7. Asp.net core 学习笔记 QR code and Barcode

    QR code 和 Barcode 经常会使用到. Java 阵营有著名的 zxing https://github.com/zxing/zxing .Net 有对接它的 port https://g ...

  8. vue2.0和animate.css的结合使用

    animate.css是一款前端动画库,相似的有velocity-animate. 上述是一个完整的结构.其中重要的几个点用箭头表示出来.首先在transition组件内部,需要定义两个基本的clas ...

  9. 9.SpringMVC注解式开发-处理器的请求映射规则的定义

    1.对请求URI的命名空间的定义 @RequestMapping的value属性用于定义所匹配请求的URI.但对于注解在方法上和注解在类上, 其value 属性 所指定的URI,意义是不同的 一个@C ...

  10. ssh-copy-id三步实现SSH无密码登录和ssh常用命令

    第一步:在本地机器上使用ssh-keygen产生公钥私钥对 $ ssh-keygen 第二步:用ssh-copy-id将公钥复制到远程机器中 $  ssh-copy-id -i .ssh/id_rsa ...