Star sky CodeForces - 835C (二维前缀和)

STM32 USB AUDIO实战指南——从零构建音频设备 本文详细介绍了如何使用STM32F407构建USB音频设备,从硬件准备到软件配置,再到音频播放和录制功能的实现。通过STM32CubeMX配置和实战代码示例,帮助开发者快速掌握USB Audio Class规范,实现低延迟、高质量的音频传输,适用于语音交互、音乐播放等多种场景。 阅读详情

Star sky

CodeForces - 835C

The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (xi, yi), a maximum brightness c, equal for all stars, and an initial brightness si (0 ≤ si ≤ c).

Over time the stars twinkle. At moment 0 the i-th star has brightness si. Let at moment t some star has brightness x. Then at moment (t + 1) this star will have brightness x + 1, if x + 1 ≤ c, and 0, otherwise.

You want to look at the sky q times. In the i-th time you will look at the moment ti and you will see a rectangle with sides parallel to the coordinate axes, the lower left corner has coordinates (x1i, y1i) and the upper right — (x2i, y2i). For each view, you want to know the total brightness of the stars lying in the viewed rectangle.

A star lies in a rectangle if it lies on its border or lies strictly inside it.


Input

The first line contains three integers n, q, c (1 ≤ n, q ≤ 105, 1 ≤ c ≤ 10) — the number of the stars, the number of the views and the maximum brightness of the stars.

The next n lines contain the stars description. The i-th from these lines contains three integers xi, yi, si (1 ≤ xi, yi ≤ 100, 0 ≤ si ≤ c ≤ 10) — the coordinates of i-th star and its initial brightness.

The next q lines contain the views description. The i-th from these lines contains five integers ti, x1i, y1i, x2i, y2i (0 ≤ ti ≤ 109, 1 ≤ x1i < x2i ≤ 100, 1 ≤ y1i < y2i ≤ 100) — the moment of the i-th view and the coordinates of the viewed rectangle.

Output

For each view print the total brightness of the viewed stars.

Examples
Input
2 3 3
1 1 1
3 2 0
2 1 1 2 2
0 2 1 4 5
5 1 1 5 5
Output
3
0
3
Input
3 4 5
1 1 2
2 3 0
3 3 1
0 1 1 100 100
1 2 2 4 4
2 2 1 4 7
1 50 50 51 51
Output
3
3
5
0
Note

Let's consider the first example.

At the first view, you can see only the first star. At moment 2 its brightness is 3, so the answer is 3.

At the second view, you can see only the second star. At moment 0 its brightness is 0, so the answer is 0.

At the third view, you can see both stars. At moment 5 brightness of the first is 2, and brightness of the second is 1, so the answer is 3.

题意:

给出 n个星星的坐标和它们的亮度si,星星最大亮度为c,t秒后星星的亮度为(si+t)%(c+1),q次询问,每次询问一个矩形区域内t秒后星星的亮度和。



思路:


开一个三维数组,记录每个前缀亮度为si的星星的个数即可

code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int sum[105][105][12];
int main(){
    int n,q,c;
    while(cin >> n >> q >> c){
        memset(sum,0,sizeof(sum));
        for(int i = 1; i <= n; i++){
            int x,y,v;
            cin >> x >> y >> v;
            sum[x][y][v]++;
        }
        for(int i = 1; i <= 100; i++){
            for(int j = 1; j <= 100; j++){
                for(int k = 0; k <= c; k++){
                    sum[i][j][k] += sum[i-1][j][k] + sum[i][j-1][k] - sum[i-1][j-1][k];
                }
            }
        }
        while(q--){
            int t,sx,sy,ex,ey,ans = 0;
            cin >> t >> sx >> sy >> ex >> ey;
            for(int i = 0; i <= c; i++){
                int x = (i + t) % (c + 1);
                ans += x * (sum[ex][ey][i] - sum[sx-1][ey][i] - sum[ex][sy-1][i] + sum[sx-1][sy-1][i]);
            }
            cout << ans << endl;
        }
    }
    return 0;
}

Xilinx_JESD204B Xilinx_JESD204B_AXI配置 说明:通过FPGA的高速数据接口JESD204B对AD9625进行高速采集。 环境:Vivado2018.3。 IP核:JESD204(7.2)。 参考手册:pg066_jesd204 v7.2。 资料以及IP_licence:JESD204B AXI协议资料:AXI 文章目录JESD204B概述JESD204B接口术语JESD204B 层JESD204B_AXI介绍AXI介绍JESD204B__AXI_Lite接口AXI-Lite接口介绍AXI-Lite接口信号 阅读详情

相关推荐

STM32 SAI接口实战:用CubeMX快速配置多通道音频采集(附DMA优化技巧)

本文详细介绍了如何使用STM32的SAI接口通过CubeMX快速配置多通道音频采集系统,并提供了DMA双缓冲优化技巧。内容涵盖TDM模式配置、时钟同步、DMA优化及常见问题排查,帮助开发者高效实现高速数据采集应用。

weixin_42549037的博客 225

Star sky CodeForces - 835C

C - Star sky CodeForces - 835C 题意:给出100*100空间种,n个星星的每个星星的位置(x,y)和初始亮度s。q次查询矩形范围内(包括边界)星星亮度的总和,星星的最大亮度是c。每个星星的亮度从0时刻的s每秒增加一个亮度一直到s,并以此循环(星星亮度范围是0-c)。 思路:三维数组。dp[x][y][k] xy表示坐标位置,k表示星星亮度。dp[x][y][k]...

DeathYmz的博客 700

别光看文档了!手把手带你用Habitat-Lab跑通第一个PointNav任务(附完整代码与避坑指南)

本文详细介绍了如何使用Habitat-Lab快速跑通第一个PointNav任务,包括环境配置、依赖安装、数据集下载与路径配置等关键步骤,并提供了完整的代码实现与常见问题排查指南。特别适合刚接触Habitat-Lab的开发者,帮助避开官方Quickstart未提及的坑,快速上手具身AI任务。

weixin_42662293的博客 270

Codeforces 835C - Star sky 【预处理前缀和】

Codeforces 835C - Star sky 【DP+前缀和】 The Cartesian coordinate system is set in the sky. There you cansee n stars, the i-th has coordinates (xi, yi), a maximum brightness c, equal for all stars, and an initialbrightness si (0 ≤ si ≤ c). Over time the stars

Dust_heart的博客 2622

BarTender破解版风险与低成本正版替代方案全解析

在工业自动化和企业信息化领域,标签打印与条形码技术是连接物理世界与数字系统的关键环节。其核心原理是通过软件驱动打印设备,将可变数据(如序列号、生产日期)与固定模板结合,生成可追溯的标识载体。这项技术的价值在于实现生产流程可视化、供应链管理精细化与质量控制自动化,广泛应用于仓储物流、制造执行、零售门店等场景。然而,软件授权合规性常成为企业成本控制的痛点,尤其面对BarTender这类行业标准工具时,部分用户可能寻求破解方案。但破解版软件通常采用内存补丁、伪造许可证等技术手段绕过验证,不仅存在法律风险,更会引发

weixin_32736961的博客 725

Kriging代理模型理论相关推导

代理模型,Kriging,加点准则

森屹的博客 1万+

CodeForces - 835C Star sky dp前缀+容斥思想

CodeForces - 835C Star sky dp前缀+容斥思想 The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (xi, yi), a maximum brightness c, equal for all stars, and an initial brightness si (0 ≤ si ≤ c). Over time the sta

ACZone 1105

【UE5.3 Cesium for Unreal】GlobePawn编译实战:从源码修改到功能实现

本文详细介绍了在UE5.3中为Cesium for Unreal插件编译和集成非官方增强组件GlobePawn的完整实战流程。从获取源码、准备资产文件、部署项目结构,到逐行修改代码适配工程并解决典型编译错误,最终实现在三维地球上实现类似Google Earth的丝滑鼠标交互体验。

weixin_29011667的博客 307

Codeforces 835C-Star sky

Star sky time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Cartesian coordinate system is set in the sky.

wang_128的博客 616

【数据集】1970-2023年全球温室气体排放 GHG 数据集 EDGAR

1970-2023年全球温室气体排放 GHG 数据集 EDGAR

WW、forever的博客 1171

VTK API 详解(103):vtkGPUVolumeRayCastMapper - GPU加速体绘制

是 VTK 中基于 GPU 的高效体绘制映射器,利用现代显卡的计算能力,通过射线投射算法实现快速且高质量的三维体积渲染。相比 CPU 版本的,GPU 映射器性能大幅提升,支持更复杂的光照和渲染效果,是体绘制的主流选择。是 VTK 中性能优异的GPU体绘制映射器;适合大数据集和实时交互应用;配合灵活设置颜色、透明度和光照;建议在支持OpenGL的环境中使用。

yumeiguo的博客 291

codeforces Star sky(二维前缀和)

传送门 C. Star sky time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Cartesian coordinate system is set

xxtz_xt的博客 672

【YOLO11改进 - C3k2融合】C3k2融合DWRSeg二次创新C3k2_DWR:扩张式残差分割网络,提高特征提取效率和多尺度信息获取能力,助力小目标检测

【YOLO11改进 - C3k2融合】C3k2DWRSeg二次创新C3k2_DWR:扩张式残差分割网络,提高特征提取效率和多尺度信息获取能力,助力小目标检测

专注于图像领域,主要研究内容包括计算机视觉和深度学习,特别是在图像分类、目标检测和图像生成等方面有深入的研究和实践经验。 1054

E - Star sky CodeForces - 835C(二维前缀和)

The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (xi, yi), a maximum brightness c, equal for all stars, and an initial brightness si (0 ≤ si ≤ c)....

tomjobs的博客 645

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

codeforces 835C Star sky (二维数组前缀和)

The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (xi, yi), a maximum brightness c, equal for all stars, and an initial brightness si (0 ≤ si ≤ c).O

henuzxy 564

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Codeforces 835C - Star sky 【预处理二维前缀和】

C. Star skytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Cartesian coordinate system is set in the sky. There you can see n stars, the i-th ...

Wwayne_的博客 390

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

CodeForces - 835C Star sky(二维前缀和)

题目链接 题意: 坐标系[0,100]×[0,100]有n个星星,亮度为si,每增加一秒,星星亮度+1,当si+1>c时,亮度变为0,给定一定矩阵的左下角、上角的点坐标和时间,求矩阵内星星的亮度和。 本来用结构体保存,再按坐标x值从小打大排序;对于左下角的坐标x值,二分查找第一个小于等于的点,再暴力计算在矩阵范围内的点的亮度值,但是n个点中可以有相同坐标的点,就毫无疑问的TLE了。因为x,y值很小,正确做法是计算二维前缀和保存当前亮度的点的个数,每次询问的答案为矩阵范围内不同亮度的个数 * 对应的亮度

qq_46667619的博客 375

Codeforces 835C Star sky【思维+暴力预处理二维前缀和】

C. Star sky time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Cartesian coordinate system is set in the s

mengxiang000000 675

Codeforces835C-Star sky(二维前缀和+思维)

Star sky time limit per test  2 seconds memory limit per test  256 megabytes input  standard input output  standard output The Cartesian coordinate system is set in the

Rain 1295

codeforces-835C. Star sky(维护二维前缀和,dp)

传送门 在不大于100*100的地图上有星星,每个星星的亮度随时间变化,它们初始亮度不同,但能达到的最高亮度相同,为C。初始亮度为p,t时刻亮度为(p+t)%(C+1) 输入 n q c(为别代表星星数目,查询次数,最高亮度) n行 x y s(星星的横纵坐标和初始亮度) q行 t x1 y1 x2 y2(查询t时刻矩阵内及边界上星星的总亮度,其中(x1,y1)是矩阵左上角,...

weixin_33860147的博客 150

Codeforces Round #427 (Div. 2) 835C-Star sky 二维前缀和

839C:http://codeforces.com/problemset/problem/835/C 题意:给出星星的个数,最大亮度(每时间+1,亮度+1,但不超过最大亮度),观测者观测的次数及时刻, 求观测时刻矩形内星星的亮度和。 这里要用到一个三维数组,一维记录时间,另外两维记录时间t时坐标(x,y)处的亮度。 星星某时刻的亮度处理:0时刻为s,此后每时间+1,亮度+1,每超过最大亮度...

weixin_30914981的博客 111

codeforces 835 C Star sky

先做一个预处理,求出sum[x][y][t],表示矩形(0,0)~(x,y) 在时间t时的所有点的亮度总和,sum[x][y][t] += sum[x-1][y][t] + sum[x][y-1][t] - sum[x-1][y-1][t]。 之后对于每个查询就可以在O(1)时间内求出,ans = sum[rx][ry][t] - sum[rx][ly-1][t] - sum[lx-1][ry][t] + sum[lx-1][ly-1][t]

Qian998的博客 1047

CodeForces 835C Star sky

题目链接:http://codeforces.com/contest/835/problem/C 题意:有一片星空这个星空里有n个星星,每个星星的位置为(xi,yi),初始亮度为si,所有星星的最大亮度为c,没过一个时间,亮度加1,达到最大c,就置为0,现在有q次询问,每此询问t时刻,(x1,y1)(x2,y2)范围里所有星星的总亮度 解析:可以直接二维树状数组来做预处理,也可以用类似一个前缀和

22h's Blog 1133

CodeForces 835C Star sky (DP)

题目链接:https://vjudge.net/problem/964309/origin 暴力记录所有时间二维前缀和即可 #include<bits/stdc++.h> using namespace std; #define debug puts("YES"); #define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++) #...

满月照亮的路 149

codeforces 835c Star sky

C. Star sky time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Cartesian coordinate system is set in the s

三水的鱼塘♂ 349

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 个查询,每个查询给出时间和一个矩...

weixin_33963189的博客 154
上一篇: The Meaningless Game CodeForces - 834C (思维题)
下一篇: Duizi and Shunzi HDU - 6188 (思维+贪心)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值