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. 【转帖】龙芯将两款 CPU 核开源,这意味着什么?

    龙芯将两款 CPU 核开源,这意味着什么? https://www.oschina.net/news/78316/loongson-open-source-two-cpu-core 文章挺不错的 也讲 ...

  2. [转帖]localectl

    localectl http://linux.51yip.com/search/localectl localectl 命令简介. 相关命令:暂无相关命令 localectl — 控制系统的本地化与键 ...

  3. C++ 简单实现 依赖注入(IOC)

    由于C++ 不支持“反射机制”, 在C++中需要实现依赖注入或控制反转需要增加辅助程序.例如在Windows 开发程序中根据类名动态创建对象,需要在类定义中增加宏.本文主要介绍C++ Ioc的一种实现 ...

  4. 超级简单的requests模块教程

    在web后台开发过程中,会遇到需要向第三方发送http请求的场景,python中的requests库可以很好的满足这一要求,这里简要记录一下requests模块的使用! 说明: 这里主要记录一下req ...

  5. django 中静态文件项目加载问题

    问题描述: django项目中创建了多个app后,每个app中都有对应的static静态文件.整个项目运行时这些静态文件的加载就是一个问题,因为整个项目我只参与了一部分,项目部署之类的并没有参与.我写 ...

  6. 编写函数模拟strcpy()函数功能

    strcpy(字符数组1,字符串2) strcpy( )用于将字符串2复制到字符数组1中 /* strcpy(字符数组1,字符串2) strcpy( )用于将字符串2复制到字符数组1中 模拟strcp ...

  7. 一块40克的砝码,摔成4块,利用天平,刚好可以称出1~40g所有整数克,问:这4块分别是多少克

    public static void main(String[] args) { List<Integer> list = new ArrayList<>();//记录每组数的 ...

  8. 核发电站 (dp前缀优化)

    大意: $n$个城市, $m$种核电站, 第$i$种假设要建在第$x$个城市, 必须满足$[x-i,x+i]$范围内无其他核电站, 求建核电站的方案数. 简单$dp$题, 设$dp[i][j]$为位置 ...

  9. iview-admin部署linux nginx报500错误的问题记录

    遇到个新服务器部署iview-admin之后 在nginx配置文件有个user配置项 这里需要配置为root或者可以读取本地文件的用户 站点配置如下 server { listen ; server_ ...

  10. 微信小程序修改radio和checkbox的默认样式和图标

    wxml: <view class="body"> <view class="body-content"> 第1题:企业的价值观是 ? ...