HDU 2870 Largest Submatrix

VASP计算层错能(SFE)全攻略2 本文介绍了使用VASP计算纯镍(Ni)层错能(SFE)的具体步骤。首先构建Ni的FCC单胞并扩展为超胞,通过修改原子位置引入堆垛层错;随后分别计算完美晶体和含层错结构的能量;最后通过能量差与层错面积之比求得SFE值。计算需注意k点网格、截断能和超胞尺寸的收敛性测试,并推荐使用PAW赝势和ASE等工具辅助结构构建。 阅读详情

传送门

这道题虽然名字叫,但并不属于最大子矩阵和问题(或许这类问题可以看成只有1和-INF的最大子矩阵和的问题?2333不过没什么用)。还是直方图dp二维化。和上一篇基本一样,只不过这个题还得重复三遍。

这道题还是让你找一个单一字母构成的最大矩形,a,b,c三种字母不能换成别的,而别的都能换成a,b,c。所以只用考虑a,b,c这三种,每考虑一种时,都让这种字母尽可能多,将其他不是这种字母的都看成另一种。

这道题还是需要注意字符输入,每行字符输入前先getchar()掉换行符。


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
using namespace std;                       // 无非分成三个问题,分别求解罢了

const int MAX = 1001;
int N, M;
int a[MAX][MAX];                           // 能变换a的都变成a
int b[MAX][MAX];
int c[MAX][MAX];
int l[MAX];                                // 下标代表列id
int r[MAX];
int ans;

void init()
{
	for (int i = 1; i <= M; i++)
		a[0][i] = b[0][i] = c[0][i] = 0;
	ans = -1;
}

void solve(int x[MAX][MAX])                // 数组作为参数
{
	int t;
	for (int i = 1; i <= N; i++)
	{
		l[1] = 1;
		for (int j = 2; j <= M; j++)
		{
			for (t = j; t - 1 >= 1 && x[i][t - 1] >= x[i][j]; t = l[t - 1]);
			l[j] = t;
		}
		r[M] = M;
		for (int j = M - 1; j >= 1; j--)
		{
			for (t = j; t + 1 <= M && x[i][t + 1] >= x[i][j]; t = r[t + 1]);
			r[j] = t;
		}
		for (int j = 1; j <= M; j++)
			ans = max(ans, x[i][j] * (r[j] - l[j] + 1));
	}
}

int main()
{
	char ch;
	for (; ~scanf("%d%d", &N, &M);)
	{
		init();
		for (int i = 1; i <= N; i++)
		{
			getchar();                       // 吸收换行
			for (int j = 1; j <= M; j++)
			{
				scanf("%c", &ch);
				if (ch == 'a' || ch == 'w' || ch == 'y' || ch == 'z')
				{
					a[i][j] = a[i - 1][j] + 1;
				}
				else a[i][j] = 0;

				if (ch == 'b' || ch == 'w' || ch == 'x' || ch == 'z')
				{
					b[i][j] = b[i - 1][j] + 1;
				}
				else b[i][j] = 0;

				if (ch == 'c' || ch == 'x' || ch == 'y' || ch == 'z')
				{
					c[i][j] = c[i - 1][j] + 1;
				}
				else c[i][j] = 0;
			}
		}

		solve(a);
		solve(b);
		solve(c);
		printf("%d\n", ans);
	}

	return 0;
}
C++11、C++14 和 C++17 标准新特性详解 特性C++11C++14C++17auto类型推导✅范围 for 循环✅Lambda 表达式✅✅✅智能指针✅移动语义✅nullptr✅统一初始化{}✅✅constexpr✅✅✅✅数字分隔符✅结构化绑定✅✅✅文件系统库✅。 阅读详情

相关推荐

内网穿透-frp二层隧道搭建

环境: weblogic: 192.168.0.133 10.10.20.12 win7 : 10.10.20.7 10.10.10.7go语言、跨平台的 可以分为frpc和frps frpc—>请求----->frps frps:放到黑客公网上 1.需要出网 2.配置: frpc:放到肉鸡上,请求frps 2.端口转发 2.1frpc传到肉鸡(weblogic) 利用工具,传入内存马到weblogic,然后使用冰蝎进行连接 然后在文件管理中上传frpc.exe和frpc.ini文件 fr

yyytaotao的博客 2103

HDU 2870 Largest Submatrix(最大完全子矩阵)

Largest SubmatrixTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2830    Accepted Submission(s): 1368Problem DescriptionNow here is a matrix wit...

BBHHTT的博客 402

安卓逆向实战:用Batch Apktool 3.8.0快速汉化APK的完整流程

本文详细解析了如何使用Batch Apktool 3.8.0进行安卓APK汉化的完整流程,包括环境配置、反编译、资源解析、深度汉化、重构建与签名优化等关键步骤。通过这款集成化逆向工具,开发者可以高效完成APK汉化,提升工作效率。

s1t2u3的博客 1099

hdu 2870 - Largest Submatrix

题目:统计一个字母矩阵中最大的相同字母的面积,有些字母可以换成其他字母。 分析:dp,单调队列。计算分三种分别换成a,b,c求出最大的子矩阵,求出最大即可。             然后就是单调队列优化的查询算法了,确定每个点右(左)边第一个比他小的点;             T(N)=O(N^2)。 说明:(2011-09-19 08:15)。 #include #include

小白菜又菜 1206

[pytorch] MedicalNet 3D Resnet预训练模型迁移学习实战:从分割到分类的代码改造

本文详细介绍了如何利用PyTorch对MedicalNet 3D ResNet预训练模型进行迁移学习,从分割任务改造为分类任务。通过解析模型结构、调整分类头、加载预训练权重及优化训练策略,帮助开发者在医疗影像领域快速实现高效模型部署。文章还涵盖了数据预处理、增强技巧及模型轻量化等实用内容。

kmeans3miner的博客 246

在昇腾910B上,用kubeadm快速拉起一个双节点K8s集群(保姆级避坑指南)

本文详细介绍了在昇腾910B服务器上使用kubeadm快速搭建双节点Kubernetes集群的完整流程,包括环境准备、容器运行时配置、kubeadm初始化、节点加入与网络插件部署等关键步骤,特别针对ARM架构和昇腾芯片提供了优化配置和避坑指南。

weixin_29204749的博客 246

hdu 2870 Largest Submatrix 最大子矩阵

题意: 有若干种 转换字母的方法,问转化后 可以得到的 最大相同字母矩阵 是多大。 矩阵大小= n*m 做法: 全转成a,然后不能的位子是0,可以的位子是1。 然后 deal 里就是一维的最大矩阵 的处理了。 是一种dp。 做法和一维的 hdu 1506 差不多。 然后再把 全是 b和c 的求出来 求最大值就好了。

万事屋 1023

智能车竞赛飞檐走壁组立体赛道电磁引导线设计与实现

本文深入解析了智能车竞赛飞檐走壁组立体赛道电磁引导线的核心设计与实现。针对垂直面、圆筒、跷跷板等立体元素,详细阐述了电磁线规格参数选择、三维空间铺设技巧及磁场调试方法,旨在帮助参赛队伍打造稳定可靠的导航系统,提升车模在复杂立体赛道上的通过率与稳定性。

bert9linguist的博客 280

51Nod 2172 ProjectEuler 6 c/c++题解

[题目描述[(http://www.51nod.com/Challenge/Problem.html#problemId=2172) 前10个正整数的平方和是 12+22+⋯+102=385 前10个正整数和的平方是 (1+2+⋯+10)2=3025 和的平方减去平方和是3025 - 385 = 2640。 输入n,求前n个正整数和的平方 减去 平方和。 输入 输入第一行组数T, 接下来T行,每...

东瓜blog 407

Codex 100个真实案例 - 用AI生成建筑平面图SVG(室内设计师的新武器)

本案例用 Codex 生成一套完整的 Python 脚本,自动绘制 SVG 格式的建筑平面图。我们会设计一个90平两室一厅的户型——客厅、主卧、次卧、厨房、卫生间一应俱全,还会自动摆放家具(沙发、床、餐桌、橱柜)、标注尺寸和面积、绘制水电路走向、生成多种配色方案。最终输出的 SVG 文件可以直接用浏览器打开展示,也可以转成 PNG 交给客户。室内设计师看了都说好!

yueyeguzhuo的专栏 761

YOLO26 终极蒸馏指南:从入门到 SOTA (The Ultimate Distillation Guide)

《YOLO26 蒸馏技术指南》深入解析了知识蒸馏在目标检测中的应用,提出五大蒸馏范式:响应蒸馏(学习最终输出)、特征蒸馏(模仿中间特征)、关系蒸馏(捕捉通道关联)、CWD(通道语义对齐)和FGD(前景背景分离)。实验表明,"Response KD + CWD + FGD"组合效果最佳,使YOLO26n在0.5ms推理速度下达到0.956 mAP50,甚至超越教师模型。指南提供模块化代码实现和超参数调优建议,强调蒸馏能平衡模型精度与效率,是轻量化部署的有效方案。

weixin_51988935的博客 717

Largest Submatrix of All 1’s--POJ3494

原题链接:http://poj.org/problem?id=3494 Description Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that the submatrix has the most elements.

ZkvIA的博客 633

windows中搭建sonic云真机环境/云真机环境搭建-基于docker容器部署

基于Windows系统搭建Sonic远程云真机环境实现通过浏览器操作手机端系统

雾林小妖的博客 1016

[HDU2870]Largest Submatrix

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description Now here is a matrix with letter ‘a’,‘b’,‘c’,‘w’,‘x’,‘y’,‘z’ and you can change ‘w’ to ‘a’ or ‘b’, ...

dxyinme-Zz 268

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

深度学习工具包 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 2870] Largest Submatrix

[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=2870 [算法] dp + 单调栈 [代码] #include<bits/stdc++.h> using namespace std; #define MAXN 1010 int i,j,n,m,a...

124

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

hdu2870 Largest Submatrix[单调栈]

这题。。 我真傻,真的。。我单知道单调队列可以优化dp,加上平衡树,却不知道单调栈就可以。。 所以说常见模型要记住 求给定矩形最大的同字母矩形面积。(字母数:a,b,c) 多组数据$n,m≤1000$ 真的学傻掉了。。写出来一个$O(n^3)$dp方程还跟真的一样去想优化。。最后只能做到$O(n^2logn)$。。 一开始大体就是对于每行的每个字母,都可以统计出前i行这...

dianer2977的博客 151

hdu 2870 Largest Submatrix

http://acm.hdu.edu.cn/showproblem.php?pid=2870 和1506 和1505类似的解法 一个关键的优化就是 if(!num[j])   continue; 说实话不是想不到,关键是懒的加,因为看起来不可能优化多少 现在知道了,以后能优化的尽量优化, 这个不加就是超时与不超时的关系 代码: #include #include #inclu

talak的专栏 447

HDU 2870 Largest Submatrix

Largest Submatrix Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 839    Accepted Submission(s): 407 Problem Description Now here is a matr...

weixin_34166472的博客 148

HDU 2870 Largest Submatrix -

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2870 #include #include #include #include using namespace std; #define max3(a,b,c) max(a,max(b,c)) const int maxn=1000+5; const int A=0,B=1,C=2; //解的

BRCOCOLI的博客 243

具身智能入门:从树莓派小车到感知-决策-执行闭环

具身智能是AI与物理世界交互的进阶形态,核心在于感知、决策、执行与学习构成的持续闭环。与静态AI不同,它必须处理传感器噪声、硬件延迟和真实环境的不确定性,这也是许多原型系统落入“死亡谷”的根因。工程实践中,系统集成与鲁棒性往往比单点算法更关键。对于初学者,仿真环境能低成本验证逻辑,但真机才是暴露问题的试金石。一辆搭载树莓派的桌面小车,是搭建最小具身智能系统的理想载体:通过摄像头识别目标、生成控制信号、驱动电机完成跟随任务,再结合数据清洗和真机排查,即可完整走通从概念到落地的链路。ROS2、OpenCV、Py

weixin_34364071的博客 330

Hdu 2870 Largest Submatrix

题目链接 题意是和POJ 1964 是一样的 看下我的这篇博客就可以知道做法了 点这里 点这里 这题的转换再看下输入是如何转换的 #include &lt;cstdio&gt; #include &lt;cstring&gt; #include &lt;iostream&gt; #include &lt;queue&gt; #include &lt;cmath&gt; #include...

我是谁 --- 卡比兽 150
上一篇: HDU 1505 City Game
下一篇: HDU 1081 To The Max
Crossing over
博客等级 码龄10年 6粉丝 113原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值