K - Mobile phones

【题解】[ IOI 2001] Mobile Phones(二维树状数组) 题面 【题目描述】 假设TampereTampereTampere区域的第四代手机基地站运行如下。该区域被划分为一些正方形(方阵)。这些正方形构成一个SSS╳SSS的矩阵,矩阵行和列的编号从000到S−1S-1S−1。每个正方形包含一个基地站。由于一个手机可能从一个正方形移动到另一个正方形,或者手机可能开机或关机,所以,在一个正方形内正在使用的手机数目是随时变化的。有时,每个基地站需要将正在使用的... 阅读详情

Time Limit: 5000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u

[Submit]   [Go Back]   [Status]

Description

Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The squares form an S * S matrix with the rows and columns numbered from 0 to S-1. Each square contains a base station. The number of active mobile phones inside a square can change because a phone is moved from a square to another or a phone is switched on or off. At times, each base station reports the change in the number of active phones to the main base station along with the row and the column of the matrix. 

Write a program, which receives these reports and answers queries about the current total number of active mobile phones in any rectangle-shaped area. 

Input

The input is read from standard input as integers and the answers to the queries are written to standard output as integers. The input is encoded as follows. Each input comes on a separate line, and consists of one instruction integer and a number of parameter integers according to the following table. 


The values will always be in range, so there is no need to check them. In particular, if A is negative, it can be assumed that it will not reduce the square value below zero. The indexing starts at 0, e.g. for a table of size 4 * 4, we have 0 <= X <= 3 and 0 <= Y <= 3. 

Table size: 1 * 1 <= S * S <= 1024 * 1024 
Cell value V at any time: 0 <= V <= 32767 
Update amount: -32768 <= A <= 32767 
No of instructions in input: 3 <= U <= 60002 
Maximum number of phones in the whole table: M= 2^30 

Output

Your program should not answer anything to lines with an instruction other than 2. If the instruction is 2, then your program is expected to answer the query by writing the answer as a single line containing a single integer to standard output.

Sample Input

0 4
1 1 2 3
2 0 0 2 2 
1 1 1 2
1 1 2 -1
2 1 1 2 3 
3

Sample Output

3
4
 
  
 
  
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std; 
#define MAXN  1300
int c[MAXN][MAXN];
int n;

int lowbit(int x)
{
	return x&(-x);
}

void updata(int x,int y,int value)
{
	int i,j;
	for(i=x;i<=n;i+=lowbit(i))
		for(j=y;j<=n;j+=lowbit(j))
			c[i][j]+=value;
}

int query(int x,int y)
{
	int i,j;
	int sum=0;
	for(i=x;i>0;i-=lowbit(i))
		for(j=y;j>0;j-=lowbit(j))
		{
			sum+=c[i][j];
		}
	return sum;
}

int main()
{
	int t;
	while(scanf("%d",&t)!=EOF)
	{
		if(t==0)
		{
			scanf("%d",&n);
			memset(c,0,sizeof(c));
		}
		else if(t==1)
		{
			int x,y,val;
			scanf("%d%d%d",&x,&y,&val);
			updata(x+1,y+1,val);
		}
		else if(t==2)
		{
			int ans;
			int x1,y2,x2,y1;
			scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
			ans=query(x1,y1)+query(x2+1,y2+1)-query(x1,y2+1)-query(x2+1,y1);
			printf("%d\n",ans);
		}	
		else if(t==3)break;		
	}
	return 0; 
}


Android 完美树形结构,可实现三态选择 Android 完美树形结构,可实现三态选择,下载即可运行,可实用与组织结构,菜单等 [注意:本资源来自网络,如有侵权,请联系我删除,谢谢。] 立即下载

相关推荐

jQuery Mobile 实现移动客户端多级下拉导航菜单

jQuery Mobile 实现移动客户端多级下拉导航菜单

IOI2001 - 移动电话

   P1294 - 【IOI 2001 】移动电话 Description 假设Tampere地区的4G移动通信基站以如下方式运行。整个地区被划分成若干正方形格子。这些格子构成一个S * S的矩阵,它们的行,列编号都是从0到S-1.每一个格子中都有一个基站。每个格子中激活的手机数量可能改变,因为一部手机可能从一个格子移动到另一个格子,打开或者关闭。有时,某一座基站会向总站...

weixin_34008784的博客 290

Jquery-ztree树形菜单代码并适应移动端

非常好用的Jquery-ztree树形菜单代码并适应移动端,可以自动配置图标

Mobile phones ( IOI2001 )

思路:用二维前缀和做,所以可以用树状数组进行维护,时间复杂度大概为O(qlognlogn)op=2时求L<=x<=R&&B<=y<=T时所有[ x ][ y ]点上数字的总和。简单翻译一下:刚输入时op=0并给出n,结束时op=3。op=1时在[ x ][ y ]这个点加上A。

xuxizhe0104的博客 1426

让 AI 学会“慢思考”:MCP Sequential Thinking 深度部署与使用指南

摘要: MCP Sequential Thinking 是一种让AI具备"慢思考"能力的技术,通过动态调整思维路径解决复杂问题。本文详细介绍了在Windows、macOS和Linux系统下的部署方法,包括环境准备、配置文件修改等步骤。该技术通过"产生想法-评估需求-修正路径"的循环机制,显著提升AI在代码设计、数学证明等复杂任务中的表现。文章还提供了验证安装方法、使用示例和常见问题解答,帮助开发者解锁AI的深层思考能力。(149字)

weixin_43236925的博客 1908

Vivado ILA调试全攻略:从HDL实例化到Block Design的5个实战技巧

本文全面解析了Vivado集成逻辑分析仪(ILA)的五种核心调试方法,涵盖从HDL代码实例化到Block Design集成的实战技巧。详细对比了不同方法的优缺点与适用场景,并重点介绍了如何利用Debug Hub高效管理多时钟域复杂调试,旨在帮助FPGA开发者精准定位问题,显著提升板级调试效率。

weixin_29214199的博客 376

Mobile Phone(二维树状数组)

Mobile Phone My Tags   (Edit) Source : IOI 2001 Time limit : 5 sec Memory limit : 32 M Submitted : 1040, Accepted : 310 PROBLEM   Suppose that th

Ninaye的博客 321

车载毫米波雷达实战:用MATLAB复现DDMA-MIMO雷达的Empty-band算法(附代码解析)

本文详细介绍了车载毫米波雷达中DDMA-MIMO技术的实战应用,重点解析了Empty-band算法的原理与MATLAB实现。通过搭建仿真环境,文章深入探讨了发射天线通道解调与相位法速度解模糊两大核心难题的解决方案,并提供了完整的代码解析,为雷达算法工程师提供了从理论到实践的清晰指南。

hill8的博客 559

poj1195——Mobile phones

题目大意:有一个边长为S的正方形区域,每个小方块内都有一个基站和很多手机,一个小方块内的活跃手机数量不固定,因为手机可以移动到其他小方块内或者可以开机关机。根据给出的一系列变化情况,输出查询的指定区域内的活跃手机个数。区域内手机总共最多2^30个。小方块内手机个数0 &lt;= V &lt;= 32767。 输入:(四种情况,输入行数范围3 &lt;= U &lt;= 60002) ...

tzyshiwolaogongya的博客 239

Unity UI适配实战:从Canvas Scaler到主流游戏适配方案解析

本文深入解析Unity UI适配的核心技术,重点介绍Canvas Scaler组件的关键参数如Reference Resolution和Screen Match Mode,并提供主流游戏适配方案实战分析。通过九宫格拉伸、动态调整等技巧,帮助开发者解决多设备适配难题,提升游戏UI在不同分辨率下的表现。

weixin_29001419的博客 972

Vue3 - 实现内网使用天地图离线地图,详解项目加载天地图的离线地图服务器部署与使用教程示例源码,vue3如何实现天地图的离线加载部署在内网访问(天地图资源下载/瓦片等流程教学,实现天地图各种功能)

Vue3中加载天地图的离线地图,天地图——内网使用离线地图,vue3+leaflet实现天地图离线访问,vue3项目中利用leaflet使用天地图,vue3项目中使用天地图离线地图,天地图离线瓦片的打包与发布(GeoServer)天地图离线瓦片数据下载及本地化部署,在内网中无法直接使用外网天地图资源怎么办,在vue3中openLayers加载地图 -使用天地图的瓦片数据。VUE3天地图离线怎么使用,内网部署天地图,天地图离线瓦片,部分瓦片数据,天地图如何离线,无需网络调用天地图API,vue天地图离线地图,

🏆 前端领域优质创作者 1万+

(POJ1195)Mobile phones <二维树状数组>

Mobile phones DescriptionSuppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The squares form an S * S matrix with t

STILLxjy 587

Docker(八):Docker Compose(容器编排) 管理多容器应用—实战案例演示

🟢 Docker(八):Docker Compose(容器编排) 管理多容器应用—实战案例演示

✨ 欢迎来到【Seal ^_^ 的优快云博客】!✨ 6万+

Mobile phones-POJ1195

Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 17445   Accepted: 8066 Description Suppose that the fourth generation mobile phone base station

编程之路 479

【完整梳理验证】企业微信第三方应用接入全流程java版

由企业内部的开发者自己开发部署,相当于是企业自己的资产,调用接口基本没有任何限制。由SaaS服务商的开发者开发并部署在服务商侧,面向所有企业。需要企业授权使用(先试用后付费),服务商仅可获取企业授权部分的权限,相当于白名单控制。由服务商的开发者开发,但部署在企业内部。一般是线下签约采购方式,因此权限几乎与自建应用无异,企业管理员只需要配置不对服务商开放的敏感权限,相当于黑名单控制。服务商后台地址:企业微信服务商官网企业管理后台地址:企业微信管理后台服务商,可以理解为 SAAS 中的运营端。企业管理端,可以理

Hello, New World! 2760

大疆RoboMaster嵌入式面试,电机FOC调不出来当场走人

摘要:大疆RoboMaster嵌入式工程师面试以实战能力著称,重点考察FreeRTOS任务调度、FOC电机控制和CAN总线三大核心技能。FreeRTOS部分涉及优先级调度、栈溢出排查及信号量与互斥锁的区别;FOC控制要求现场编写电流环代码,并解释Clarke/Park变换原理;CAN总线则关注仲裁机制、CANopen协议应用及错误帧排查方法。面试强调工程实践,需具备STM32开发经验,建议搭建实际环境进行练习。该岗位被誉为"硬件版修罗场",充分体现大疆对实际开发能力的严格要求。

郑伟强dev的专栏 150

POJ1195——Mobile phones(二维树状数组)

二维树状数组的模板题

Reverie 482

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

POJ 1195 Mobile phones 【二维树状数组】

传送门:POJ 1195 Mobile phones Time Limit: 5000MS Memory Limit: 65536K Problem Description Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The ar...

Waiting For You 187

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

poj1195--Mobile phones(二维树状数组)

Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 15182   Accepted: 7013 Description Suppose that the fourth generation mobile phone base stations

随风的专栏 1736

Devexpress16.2.6破解工具

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

poj 1195 -- Mobile phones(2维树状数组)

<br />Mobile phonesTime Limit: 5000MS Memory Limit: 65536K<br />Total Submissions: 8215 Accepted: 3596<br /><br /><br />Description<br />Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is div

蓝色污点的专栏 822

poj1195 Mobile phones

Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 10738   Accepted: 4902 Description Suppose that the fourth generation mobile phone base sta

喵呜的Blog 943

POJ1195 Mobile phones 【二维线段树】

Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 14291   Accepted: 6644 Description Suppose that the fourth generation mobile phone base stati

长风的专栏 1508

【POJ 1195】Mobile phones

Mobile phones Time Limit:5000MS Memory Limit:65536K Total Submissions:17421 Accepted:8049 Description Suppose that the fourth generation mobile phone ba...

a5615024的博客 166

POJ 1195 Mobile phones

Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 12408   Accepted: 5718 Description Suppose that the fourth generation mobile phone base stations

ACM2272902662的专栏 841

Poj 1195 Mobile phones

If you are a prison, I would like to in your heart...

Follow My Heart 711
上一篇: J - Necklace
下一篇: L - Play on Words
翔蝈蝈
博客等级 码龄16年 25粉丝 69原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值