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

Blender入门教程-3D视图界面介绍 3D视图用于与3D场景交互,可用于各种目的,例如建模、动画、纹理绘制等。在关闭 启动画面 后,启动场景会显示在3D视口中(如果没有加载其他blend文件)。01 标题栏标题栏包含了基于当前 模式 的各种菜单和控制。 阅读详情

题目链接:POJ 1195 Mobile phones

Mobile phones

Time Limit: 5000MS Memory Limit: 65536K
Total Submissions: 21926 Accepted: 10200

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

Source

 

题目大意:

有四种操作:

0 -- N 初始化一个 N*N 的矩阵;

1 -- X -- Y -- Value  在矩阵的点(X,Y)加上 Value;

2 -- X_1-- Y_1 -- X_2 -- Y_2   查询左上角坐标为(X_1, Y_1) && 右下角坐标为(X_2, Y_2) 子矩阵的和

3 结束程序

大概思路:

使用二维树状数组模拟,需要注意的是

①题目下标从0开始,但是树状数组下标从1开始

②因为维护的是前缀和,所以求子矩阵的和等于删掉上边的和左边的再加上重复删掉的部分

 

AC code(4556K 516MS):

 1 #include <map>
 2 #include <set>
 3 #include <list>
 4 #include <stack>
 5 #include <queue>
 6 #include <vector>
 7 #include <math.h>
 8 #include <bitset>
 9 #include <stdio.h>
10 #include <cstring>
11 #include <climits>
12 #include <iostream>
13 #include <algorithm>
14 #define INF 0x3f3f3f3f
15 #define ll long long int
16 using namespace std;
17 
18 const int MAXN = 1100;
19 int c[MAXN][MAXN];
20 int N;
21 
22 int lowbit(int x)
23 {
24     return x&(-x);
25 }
26 
27 void add(int x, int y, int value)
28 {
29     for(int i = x; i <= N; i+=lowbit(i))
30         for(int j = y; j <= N; j+=lowbit(j))
31             c[i][j]+=value;
32 }
33 
34 int sum(int x, int y)
35 {
36     int res = 0;
37     for(int i = x; i > 0; i-=lowbit(i))
38         for(int j = y; j > 0; j-=lowbit(j))
39         res+=c[i][j];
40     return res;
41 }
42 
43 void MEM()
44 {
45     for(int i = 0; i <= N; i++)
46         for(int j = 0; j <= N; j++)
47             c[i][j] = 0;
48 }
49 int main()
50 {
51     ll ans;
52     int com;
53     int xi, yi, v, x1, x2, y1, y2;
54     while(~scanf("%d", &com))
55     {
56         if(com == 3) break;
57         else if(com == 0)
58         {
59             scanf("%d", &N);
60             MEM();
61         }
62         else if(com == 1)
63         {
64             scanf("%d%d%d", &xi, &yi, &v);
65             add(xi+1, yi+1, v);
66         }
67         else if(com == 2)
68         {
69             scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
70             x1++, y1++, x2++, y2++;
71             ans = (sum(x2, y2) + sum(x1-1, y1-1) - sum(x2, y1-1) - sum(x1-1, y2));
72             printf("%lld\n", ans);
73         }
74     }
75     return 0;
76 }

 

产品包装质检实战:基于YOLOv5的智能包装合格检测系统全流程指南 摘要: 针对产品包装质检效率低、漏检率高的问题,本文提出基于YOLOv5的智能检测系统。系统通过采集包装缺陷数据(破损、缺标、封装不良等),利用YOLOv5实现多类别缺陷识别(准确率≥95%),并开发Flask Web界面实现检测可视化与报告生成。实验表明,该系统在30帧/秒的产线速度下可稳定运行,显著提升质检效率。项目涵盖数据标注、模型训练、系统开发全流程,具有工业落地价值,适用于智能制造场景的自动化质检需求。(149字) 阅读详情

相关推荐

09、Flutter FFI Dart Native API

本文介绍了 Dart Native API 的基本用法,解决了 Dart 与 C 异步通讯的问题

eieihihi的专栏 4403

POJ 1195 Mobile phones

 Mobile phonesTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 6524 Accepted: 2755DescriptionSuppose that the fourth generation mobile phone base station

bobten2008的专栏 962

【SLAM论文笔记】SplaTAM论文小结

参考方法有ORB-SLAM3、Point-SLAM、NICE-SLAM、Kintinuous、ElasticFusion,测试数据集有ScanNet++、Replica、TUM-RGBD、Orig-ScanNet,SpaTAM并未在全部对比均为第一,表现最佳的是在ScanNet++、Replica,ScanNet++上SplaTAM方法位姿精度比第2名ORB-SLAM3高两个数量级,在TUM。上无稀疏SLAM结果,NICE-SLAM与Point-SLAM占优。SplaTAM基本做到了SOTA。

持之以恒 1011

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

【异常】Cursor 模型服务地域访问限制报错的完整排查与解决方案This model provider doesn‘t serve your region

其本质是:Cursor客户端依赖的上游大语言模型服务提供商,基于自身服务的合规运营范围,对客户端发起的请求进行了来源地域权限校验;当系统检测到请求的网络来源地域,不在该模型服务商官方授权提供服务的地域范围内时,会触发服务访问拦截策略,拒绝响应本次模型调用请求,最终在客户端抛出该报错。合规声明:本文所提供的所有方案,均仅用于技术问题排查与解决,请您在使用过程中严格遵守当地法律法规,以及对应软件与模型服务提供商的用户协议与合规要求。更多关于AI+教育领域的干货,可以关注我的微信公众号一时间获取哦~

奶爸的编程之路,也就一周冷个三天 1134

组建高效AI开发团队:角色、技能与协作

在当今科技飞速发展的时代,人工智能(AI)已经成为各个领域的核心驱动力。组建高效的AI开发团队对于企业和科研机构来说至关重要,它能够推动创新、提高竞争力、实现业务目标。本文的目的在于为那些希望组建或优化AI开发团队的管理者、技术负责人以及相关从业者提供全面的指导。范围涵盖了团队角色的定义、所需技能的分析、团队协作的策略,以及实际项目中的应用和相关资源的推荐。本文将首先介绍AI开发团队的核心概念与联系,包括团队角色、技能和协作之间的关系。接着阐述核心算法原理和具体操作步骤,结合数学模型和公式进行详细讲解。

2502_91592937的博客 995

poj-1195-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 the rows and col

long-long-ago 453

maxim max96712+max96717调试笔记

mxxim max96712 和max96717调试笔记

libuping2023的博客 1万+

1195 Mobile phones 二维树状数组

Mobile phonesTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 6843 Accepted: 2905DescriptionSuppose 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

kongming_acm的专栏 567

ZYNQ PS-PL数据交互方式总结

一,中断 二,IO方式:MIO EMIO GPIO 三,BRAM或FIFO或EMIF (1)通过BRAM实现PL/PS之间交互 PS 的配置如下图所示。使能 M_AXI_GP0 口,将 FCLK_CLK0 设为 100MHz,使能 PL 至 PS 的中断。 AXI BRAM Controller IP 核连接 PS 的 M_AXI_GP0 口和 BRAM,完成 AXI 接口至 BRAM 接口的转换。 添加BRAM,将BRAM设置为双口RAM,将PORTA与AXI B...

wangjie36的博客 1万+

电子图像增稳(EIS)原理详解——从抖动补偿到代码实现

电子图像增稳(EIS)是一种通过软件算法实现视频稳定的技术,广泛应用于GoPro、手机和无人机等设备。与光学防抖(OIS)和机械云台不同,EIS通过图像裁切和运动补偿来消除抖动,具有成本低、补偿范围大的优点,但会损失10-30%的画幅。其核心流程包括运动检测、抖动分离、运动补偿和图像裁切四个步骤。相比硬件方案,纯软件实现的EIS更适合消费级电子产品,已成为移动设备视频拍摄的重要技术。

电脑管家 412

POJ 1195 Mobile phones (二维树状树组)

由于英语极差,看了半天也没看懂题目,最后参考了其他人的题解才搞懂题目,我就直接把题意贴过来了 题意:这道题目只是题意自己就去理解了半天,大概题意如下:给出i一个n*n的矩阵,初始化为均为0,还有关于这个矩阵的几种操作,操作如下:命令1:(X Y A)对位于坐标(X Y)的值加A;命令2:(L B R T)求出位于L<=x<=R,B&...

185

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

POJ1195 Mobile phones【二维树状数组】

Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 25904 Accepted: 11812 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

海岛Blog 481

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

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

Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 17500 Accepted: 8093Description Suppose that the fourth generation mobile phone base stations in the Tampere area

ATOD 828

Devexpress16.2.6破解工具

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

二维树状数组 —— POJ 1195 Mobile phones

二维树状数组 —— POJ 1195 Mobile phones

大田二十 574

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

【poj1195】Mobile phones(二维树状数组)

题目链接:http://poj.org/problem?id=1195 【题意】 给出一个全0的矩阵,然后一些操作 0 S:初始化矩阵,维数是S*S,值全为0,这个操作只有最开始出现一次 1 X Y A:对于矩阵的X,Y坐标增加A 2 L B R T:询问(L,B)到(R,T)区间内值的总和 3:结束对这个矩阵的操作 【思路】 二维树状数组单点更新+区域查询,可作为...

ayci54153的博客 112

POJ1195 Mobile phones 二维树状数组

题目链接:http://poj.org/problem?id=1195 题目大意:给出一个n*n的矩阵,两种操作:“1 x y v”表示将矩阵上的点(x,y)加上v;“2 x1 y1 x y”表示查询矩阵的和。 分析:和HDU2645 Stars类似,很裸的二维树状数组的题。 实现代码如下: #include #include #include using n

AC_Gibson的专栏 615

二维树状数组模板题 poj 1195 Mobile phones

给定一个矩阵和三种操作 1 a b x表示把[a,b]值加上x,2 L B R T表示L <= x <= R , B <= y <= T 求这个小矩形的面积 3表示输入结束

ACM_10000h的专栏 922

POJ 1195 Mobile Phones 二维树状数组

1 #include<iostream> 2 #include<math.h> 3 #include<string.h> 4 #include<queue> 5 #include<algorithm> 6 #include<cstdio> 7 #define rep(i,a,n) f...

b479093573011909的博客 199

poj1195 Mobile phones-二维 树状数组

题目链接: http://poj.org/problem?id=1195 Mobile phones Time Limit:5000MS Memory Limit:65536K Total Submissions:23026 Accepted:10653 Description Sup...

Source_Roc 199

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

二维数组应用

Gzbgreat的博客 383

poj1195 Mobile phones 二维树状数组

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

kimnoic的专栏 365

【POJ1195】【二维树状数组】Mobile phones

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...

Gregory99174的博客 114

POJ 1195 (Mobile phones) 二维树状数组

题目链接:http://poj.org/problem?id=1195 题意:给出一个矩阵及一些操作,求一些子矩阵的和。 思路:二维树状数组裸题,要注意下标从0开始,所以可以在输入后对每个坐标值都加1。 #include #include #include #include #include #include #include #include #include #include #

Interstellar_的博客 408

poj1195 Mobile phones(二维树状数组)

http://poj.org/problem?id=1195 题意:(一大坨的题)给你4种操作,0代表输入矩阵的宽度建立矩阵,1代表对矩阵中第x行y列的数加上a,2代表对坐标点(l,b)~(r,t)矩阵内的所有点求和并输出,3代表退出。 思路:首先看教程,二维树状数组说白了就是横向为1,2,1,4,1,2,1,8这样的树状数组,纵向也为1,2,1,4,1,2,1,8这样的树状数组,

Iguodala的博客 471
上一篇: POJ 2365【YY水题】
下一篇: (第三场) C Shuffle Cards 【STL_rope || splay】
莜莫oO
博客等级 码龄9年 7粉丝 226原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值