CodeForces 835C - Star sky | Codeforces Round #427 (Div. 2)
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)的更多相关文章
- Codeforces 835C - Star sky - [二维前缀和]
题目链接:http://codeforces.com/problemset/problem/835/C 题意: 在天空上划定一个直角坐标系,有 $n$ 颗星星,每颗星星都有坐标 $(x_i,y_i)$ ...
- CodeForces 835D - Palindromic characteristics | Codeforces Round #427 (Div. 2)
证明在Tutorial的评论版里 /* CodeForces 835D - Palindromic characteristics [ 分析,DP ] | Codeforces Round #427 ...
- 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 ...
- 动态规划:Codeforces Round #427 (Div. 2) C Star sky
C. Star sky time limit per test2 seconds memory limit per test256 megabytes inputstandard input outp ...
- Codeforces Round #427 (Div. 2)—A,B,C,D题
A. Key races 题目链接:http://codeforces.com/contest/835/problem/A 题目意思:两个比赛打字,每个人有两个参数v和t,v秒表示他打每个字需要多久时 ...
- Codeforces Round #427 (Div. 2)
B. The number on the board 题意: 有一个数字,它的每个数位上的数字的和不小于等于k.现在他改变了若干位,变成了一个新的数n,问现在的数和原来的数最多有多少位不同. 思路: ...
- 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 ...
- 【Codeforces Round #427 (Div. 2) C】Star sky
[Link]:http://codeforces.com/contest/835/problem/C [Description] 给你n个星星的坐标(xi,yi); 第i个星星在第t秒,闪烁值变为(s ...
- 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 ...
随机推荐
- Oracle参数文件修改
初始化参数文件有两种,文本初始化参数文件 pfile 和二进制初始化参数文件 spfile. 动态参数文件spfile 这是Oracle推荐的初始化参数文件类型.这是一个可以写入和读取的二进制文件 ...
- selenium登录实验楼
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.s ...
- 采样方法(二)MCMC相关算法介绍及代码实现
采样方法(二)MCMC相关算法介绍及代码实现 2017-12-30 15:32:14 Dark_Scope 阅读数 10509更多 分类专栏: 机器学习 版权声明:本文为博主原创文章,遵循CC 4 ...
- C#学习基础资料记录---字典(Dictionary),时间表示方法(DateTime.Now),文件操作
1.字典 https://www.cnblogs.com/gengaixue/p/4002244.html 2.时间的表示方法 DateTime.Now的多种用法 https://www.cnblog ...
- StoneTab标签页CAD插件 3.1.0
//////////////////////////////////////////////////////////////////////////////////////////////////// ...
- C#通讯框架改写
现有项目是利用C#的socket与PLC进行实时通讯,PLC有两种通讯模式——常规采集&高频采集. 其中常规采集大概在10ms左右发送一次数据,高频采集大概在2ms左右发送一次数据. 现有代码 ...
- dotnet跨平台 - 使用Nginx+Docker Compose运行.NETCore项目
参考文档: https://docs.docker.com/install/linux/docker-ce/centos/ http://www.dockerinfo.net/document htt ...
- Spring的启动流程
spring的启动是建筑在servlet容器之上的,所有web工程的初始位置就是web.xml,它配置了servlet的上下文(context)和监听器(Listener),下面就来看看web.xml ...
- CentOS系统 Amoeba+MySql主从读写分离配置 适合新手傻瓜式教程!-----仅供参考!
废话不说,直接开始: 一.安装mysql的三种方式,这里采用第2种(安装方式不再详解,请参照) http://www.cnblogs.com/babywaa/articles/4837946.html ...
- NORDIC 错误文件
ble_err.h sdk_errors.h nrf_error.h app_error.h