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. 使用kubeadm进行单master(single master)和高可用(HA)kubernetes集群部署

    kubeadm部署k8s 使用kubeadm进行k8s的部署主要分为以下几个步骤: 环境预装: 主要安装docker.kubeadm等相关工具. 集群部署: 集群部署分为single master(单 ...

  2. H3C路由器登录策略专题讲解

    password-control login-attempt login-times [ exceed { lock | lock-time time | unlock } ] undo passwo ...

  3. work note

    eclipse git 察看历史 左边是提交的 import { NgModule } from '@angular/core'; import { IonicPageModule } from 'i ...

  4. C#读写操作app.config中的数据

    <?xml version="1.0" encoding="utf-8" ?> <configuration> <connecti ...

  5. 恩佐夫博弈+JAVA大数

    题意:http://acm.hdu.edu.cn/showproblem.php?pid=5973 根号5复制后200位就行了,因为BigDecimal不支持开根号,除法二分开根. import ja ...

  6. 测试常用__linux命令

    1.显示目录和文件的命令 Ls:用于查看所有文件夹的命令. Dir:用于显示指定文件夹和目录的命令 Tree: 以树状图列出目录内容 Du:显示目录或文件大小 2.修改目录,文件权限和属主及数组命令 ...

  7. DaemonSet和StatefulSet

    DaemonSet 的使用 通过该控制器的名称我们可以看出它的用法:Daemon,就是用来部署守护进程的,DaemonSet用于在每个Kubernetes节点中将守护进程的副本作为后台进程运行,说白了 ...

  8. Python 异常处理与反射机制

    Python 的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC语言的一种继承.Py ...

  9. 2017多校赛 Function

    Function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  10. php.ini中allow_url_fopen和allow_url_include的设置

    all_url_include在php 5.2以后添加,安全方便的设置(php的默认设置)为:allow_url_fopen=on;all_url_include=off;allow_url_fope ...