HDU1559 最大子矩阵 (二维树状数组)

YOLOv8n轻量化实战:10分钟打通实时摄像头目标检测,附参数调优与避坑指南 本文介绍了如何快速入门YOLOv8目标检测框架,通过摄像头实战实现实时检测。YOLOv8凭借轻量化架构和跨平台优势,是新手入门的理想选择。文章详细讲解了环境搭建(1分钟完成)、核心代码逻辑(3分钟掌握)以及性能调优技巧(3分钟进阶),提供可直接运行的代码示例。重点包括:模型选择(优先yolov8n.pt)、摄像头参数优化、置信度阈值调整、检测类别指定等实用技巧,帮助开发者快速实现10-15FPS的实时检测效果,并针对不同场景提供优化建议。 阅读详情

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1559

题目大意:给一个n*m的矩阵,求一个x*y的最大子矩阵和。

思路:sum(x,y) = query(i,j) - query(i-x,j) - query(i,j-y) + query(i-x,j-y)。然后二维树状数组求解即可。

#include <bits/stdc++.h>
using namespace std;

int t,n,m,x,y,ans,a[1005][1005],tree[1005][1005];

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

void update(int x, int y, int num){
	for(int i = x; i <= n; i += lowbit(i)){
		for(int j = y; j <= m; j += lowbit(j))
			tree[i][j] += num;
	}
}

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

int main(){
	scanf("%d",&t);
	while(t --){
		scanf("%d%d%d%d",&n,&m,&x,&y);
		memset(tree,0,sizeof(tree));
		for(int i = 1; i <= n; i ++)
			for(int j = 1; j <= m; j ++){
				scanf("%d",&a[i][j]);
				update(i,j,a[i][j]);
			} 
				
		ans = -1;
		for(int i = x; i <= n; i ++){
			for(int j = y; j <= m; j ++){
				ans = max(ans,query(i,j) - query(i,j-y) - query(i-x,j) + query(i-x,j-y));
			}
		}		
		printf("%d\n",ans);
	}
	return 0;
}



基于STM32的室内环境监测系统设计与实现 摘要 本文设计了一种基于STM32的室内环境监测系统,通过传感器实时采集温湿度、空气质量、烟雾浓度等数据,并利用Wi-Fi模块上传至云服务器。系统采用STM32F103C8T6作为主控芯片,结合DHT11、MQ系列传感器及BMP280气压传感器实现数据采集,通过ESP8266模块实现远程数据传输。用户可通过手机APP实时查看环境参数,并在数据超标时触发报警。实验表明,系统运行稳定,监测精度高,具有低成本、易扩展等特点,为改善室内环境质量提供了有效解决方案。 关键词:STM32;室内环境监测;传感器;Wi-F 阅读详情

相关推荐

基于Arduino UNO的OLED显示器使用方法x2(Arduino系列五)

Arduino使用OLED显示模块可以实现串口数据显示,还可以与其他模块联合使用,实现实时显示开发板实时数据。

LNN0212的博客 4175

HDOJ 1559 最大子矩阵

纯属涨自信用。。。。。。最大子矩阵Time Limit: 30000/10000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2217Accepted Submission(s): 1119Problem Description给你一个m×n的整数矩阵,在上面找一个x×y...

weixin_30235225的博客 231

QTableView实现表格加载百万条数据

本文介绍用QTableView实现加载100万条数据显示到表格。 1.创建工程 用Qt Creator创建Qt Widgets Application项目,基类选择QWidget,创建好了,如图: 2.添加QTableView控件 在widget.ui中添加QTableView控件,和QPushButton,采用栅格布局,如图: 3.添加函数 头文件 QT_BEGIN_NAMESPACE namespace Ui { class Widget; } QT_END_NAMESPACE class Wid

丁爸的博客 8273

HDU 1559 最大子矩阵

简单DP,以DP[i][j]来记录从第一个点开始,大小为i,j的矩阵的和,则dp[i][j] = rsum+dp[i-1][j],rsum为当前行到这个点的和。 以点(i,j)为右下角的大小为x,y的矩阵的和为dp[i][j]-dp[i][j-y]-dp[i-x][j]+dp[i-x][j-y],答案就是这里面出现过的最大值。 #include #include #include #in

little_胖的专栏 444

k-Wave仿真例程:创建超声换能器并绘制声场分布

k-Wave软件是为了模拟超声波在1D、2D或3D中的传播。应用示例包括:- 均匀和非均匀介质中的传播- 模拟各种类型的传感器- 模拟多普勒效应- 衍射、折射和反射- 光声、超声成像- 波束合成、成像重建- 模拟弹性波。

weixin_38452364的博客 6350

Kettle Web版部署指南

看到以上的日志则表示启动成功。

2401_89221867的博客 1728

HUD-1559 最大子矩阵,dp模拟

最大子矩阵 Time Limit: 30000/10000 MS (Java/Others) ...

weixin_30590285的博客 140

2.2.1.3-移动平均线(python画k线、均线、5日线、买卖点图、python均线策略)

* 绘制一个k线图,也就是蜡烛图 * 计算5日均线值、10日均线值 * 在k线图上,绘制5日线和10日线图 * 在5日线上,绘制与10日线的交叉点(上穿、下穿时) python画k线、均线、5日线、买卖点图、python均线策略

KelvinLiu 3419

【杭电1559】最大子矩阵

最大子矩阵 Time Limit: 30000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4161    Accepted Submission(s): 2170 Problem Description 给你一个m×n的整数矩阵,在上面找一

better_space的博客 493

【002】C++ 语言核心:关键字深度解析与分类指南

auto:自动类型推导bool:布尔类型break:跳出循环或switch语句case:switch语句分支char:字符类型class:定义类const:常量continue:结束当前循环,开始下一次循环default:switch语句默认分支delete:删除对象do:do-while循环double:双精度浮点数类型else:if语句的否定分支enum:枚举类型explicit:显式构造函数export:导出符号extern:声明外部变量或函数。

Lion_Long的博客 1254

KingSCADA3.8保姆级安装教程

大家好,我是雷工!最近开始学习KingSCADA,今天这篇详细记录安装KingSCADA3.8的过程。首先下载需要的安装版本,此处以从官网下载的最新版本KingSCADA3.8为例,双击:Setup.exe;

做有价值的事,积累有价值的笔记! 1万+

HDU - 1559 最大子矩阵(dp)

给你一个m×n的整数矩阵,在上面找一个x×y的子矩阵,使子矩阵中所有元素的和最大。 Input输入数据的第一行为一个正整数T,表示有T组测试数据。每一组测试数据的第一行为四个正整数m,n,x,y(0 Output对于每组数据,输出一个整数,表示子矩阵的最大和。 Sample Input 1 4 5 2 2 3 361 649 676 588 992 762 156 993 169 66

zitian246的博客 406

《UDS协议从入门到精通》系列——到底什么是DTC?

到底什么是DTC?看这里,深度图解DTC格式,详述DTC状态位、快照信息和扩展信息!!

车载系统攻城狮 1万+

【二维树状数组】hdu 1559 最大子矩阵

二维树状数组求子矩阵和

Gzbgreat的博客 414

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

hdu 1559 最大子矩阵(二维树状数组)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1559点击打开链接 最大子矩阵 Time Limit: 30000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5036    Accepted S

xuejye的博客 510

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

hdu1559 最大子矩阵(二维树状数组 模板)

Problem Description 给你一个m×n的整数矩阵,在上面找一个x×y的子矩阵,使子矩阵中所有元素的和最大。 Input 输入数据的第一行为一个正整数T,表示有T组测试数据。每一组测试数据的第一行为四个正整数m,n,x,y(0<m,n<1000 AND 0<x<=m AND 0<y<=n),表示给定的矩形有m行n列。接下来这个矩阵...

。 186

计算机控制技术及应用

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

php求二维矩阵的最大子矩阵,HDU1559 最大子矩阵 (二维树状数组)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1559最大子矩阵Time Limit: 30000/10000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2901Accepted Submission(s): 1454P...

weixin_39621427的博客 122

hdu-1559 最大子矩阵(二维树状数组模板题)

最大子矩阵 Time Limit: 30000/10000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5994Accepted Submission(s): 3143 Problem Description 给你一个m×n的整数矩阵,在上面找一个x×y的子矩阵...

weixin_30815469的博客 187

【HDU 1559】最大子矩阵(二维树状数组)

 最大子矩阵 Time Limit: 30000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4626    Accepted Submission(s): 2398 Problem Description 给你一个m×n的整数矩阵,在上面

FSMM_blog 359

HDU1559 最大子矩阵(二维树状数组)

最大子矩阵 Problem Description 给你一个m×n的整数矩阵,在上面找一个x×y的子矩阵,使子矩阵中所有元素的和最大。 Input 输入数据的第一行为一个正整数T,表示有T组测试数据。每一组测试数据的第一行为四个正整数m,n,x,y(0<m,n<1000 AND 0<x<=m AND 0<y<=n),表示给定的矩形有m行n列。接下来这个矩阵,有m行,每行有n个不大于1000的正整数。

_ostreamBaba 485

HDU 1559 最大子矩阵(二维树状数组)

Problem Description 给你一个m×n的整数矩阵,在上面找一个x×y的子矩阵,使子矩阵中所有元素的和最大。 Input 输入数据的第一行为一个正整数T,表示有T组测试数据。每一组测试数据的第一行为四个正整数m,n,x,y(0&lt;m,n&lt;1000 AND 0&lt;x&lt;=m AND 0&lt;y&lt;=n),表示给定的矩形有m行n列。接下来这个矩阵,有m行,每...

第一楼主的博客 578

HDU 1559 最大子矩阵 [二维树状数组]【数据结构】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1559 ———————————————————————————————. 最大子矩阵Time Limit: 30000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4

Tabris的博客 414

HDU:1559 最大子矩阵

题目: 给你一个m×n的整数矩阵,在上面找一个x×y的子矩阵,使子矩阵中所有元素的和最大。 Input 输入数据的第一行为一个正整数T,表示有T组测试数据。每一组测试数据的第一行为四个正整数m,n,x,y(0<m,n<1000 AND 0<x<=m AND 0<y<=n),表示给定的矩形有m行n列。接下来这个矩阵,有m行,每行有n个不大于1000的正整数。 Output 对于每组数据,输出一个整数,表示子矩阵的最大和。 Sample Input 1 4 5 2 2 3 3

_Kiwi_berry的博客 295

100道动态规划——21 HDU 1559 最大子矩阵和 树状数组 最大连续子区间和

好吧,拿一个简单的DP来练练手(捂脸) 看到的第一眼就想到最大连续子区间和的问题,然后想办法往上面靠 我用的不是二维树状数组,而是n个一维的树状数组,通过枚举子矩阵的行数,转化为最大连续子区间和 估计是个n^3lgn的复杂度,算上树状数组的查询的话,因为数据量小,也就过去了。 #include #include #include using namespace std; int

Sion 1352

最大子矩阵(二维树状数组)

最大子矩阵 Time Limit: 30000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5141 Accepted Submission(s): 2714Problem Description 给你一个m×n的整数矩阵,在上面找一个x×y的子矩阵,使子

Lancer 398

hdu 1559(最大子矩阵)

最大子矩阵 Time Limit: 30000/10000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3906Accepted Submission(s): 1994 Problem Description 给你一个m×n的整数矩阵,在上面找一个x×y的子矩阵,使...

weixin_30810583的博客 137
上一篇: HDU1556 Color the ball (树状数组)
下一篇: hdu1061 Rightmost Digit 【快速幂模板】
TooSIMple_
博客等级 码龄11年 99粉丝 415原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值