qduoj 分辣条1 (搜索+剪枝)

ACM之坑&套路 写在前边:这些梗都是敝人自己做题和比赛时曾经坑过自己的地方,特别在这里记录一下,所有的链接都是本博客中的题解链接(有大致题意说明和代码),原题请到OJ上自行寻找。目的是提升自身姿势。欢迎大佬们给我提出更好的建议,十分感谢。 #1:一些写法的线段树需要开四倍空间。大概是因为:在很靠近叶子的地方,他的编号就很接近2倍了。然后他的孩子(超生)就接近4倍了。 例如:Codeforces 833B ... 阅读详情

分辣条

发布时间: 2016年6月26日 20:36   最后更新: 2016年6月26日 20:37   时间限制: 1000ms   内存限制: 128M

“你喝的酸奶是我买的,辣条也是我买的,你现在要跟我分手,你把我当什么?”

“因为你每次分辣条的时候都比我多一根!”

可见分好辣条是一件多么重要的事情。。

现在有n(1<=n<=200)根辣条,每根辣条的重量为a1,a2...ai..an(1<=ai<=100)。

那么能不能把这些辣条分为重量相等的两份呢?

输入有多组数据。 每组数据第一行为一个整数n(1<=n<=200),n代表辣条的数量。 第二行有n个整数,a1,a2...ai..an,其中ai(1<=ai<=100)代表第i根辣条的重量

若能分成重量相等的两份,则输出"YES",否则输出"NO"每个答案占一行

复制
3
1 2 1
4
1 1 1 2
YES

NO

/*

这题和poj2362基本一模一样吧

*/

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 205;
int n, a[maxn], avg, maxl, flag;
bool book[maxn];
void dfs(int num, int cur)
{
    if(flag) return ;
    if(num == avg) { flag = 1; return ; }
    for(int i = cur; i < n; i++)
    {
        if(num + a[i] > avg) return ;   //剪枝2,因为有序,到这根时已经过重,更不用说后面的了
        if(!book[i] && num+a[i] <= avg)
        {
            book[i] = 1;
            dfs(num+a[i], i+1);
            book[i] = 0;
            if(flag) return ;   //剪枝3, 一找到就回
        }
    }
}
int main(void)
{
    while(cin >> n)
    {
        memset(book, 0, sizeof(book));
        maxl = avg = flag = 0;
        for(int i = 0; i < n; i++)
        {
            scanf("%d", &a[i]);
            if(a[i] > maxl) maxl = a[i];
            avg += a[i];
        }
        if(avg % 2 || maxl > avg/2) printf("NO\n");     //剪枝1, 对不能平分和单个辣条过重的进行剪枝
        else
        {
            avg /= 2;
            sort(a, a+n);       //便于之后剪枝
            dfs(0, 0);
            if(flag) printf("YES\n");
            else printf("NO\n");
        }
    }
    return 0;
}


6、探索音乐结构中的统一性:贝多芬《英雄交响曲》第一乐章的深度剖析 本文深入剖析了贝多芬《英雄交响曲》第一乐章的音乐结构,探讨其统一性的来源及表现形式。通过主题与动机、和声与调性、旋律与节奏、织体与动态等多方面的分析,揭示了这部作品在技术层面和情感表达上的卓越成就。 阅读详情

相关推荐

SAP PCC成本收集器实战:从配置到结算的完整流程解析

本文详细解析了SAP PCC成本收集器从配置到结算的完整流程,特别适用于重复制造行业。通过实战案例和配置要点,帮助用户掌握物料分类账管理、成本中心费用归集及差异分析等核心功能,提升企业生产成本控制效率。

weixin_29251567的博客 896

qduoj 分辣条2(完全背包,装满问题)

分辣条2 发布时间: 2016年7月2日 21:47   最后更新: 2016年7月2日 21:51   时间限制: 1000ms   内存限制: 128M 描述 啊啊有根很大的辣条,重量为n,啊啊想把辣条分给很多小朋友,但是必须满足下列条件: 1.每个小朋友分得的辣条重量为a,b或c; 2.分得辣条的小朋友的数量最多; 3.没有剩余的辣条,也就是说所有辣条都分完啦。 帮

CillyB的博客 978

从碰撞电离到雪崩击穿:Sentaurus仿真中的模型选择与验证艺术

本文深入探讨了Sentaurus TCAD中雪崩击穿模型的选取与验证方法,特别关注平行平面结的仿真实践。通过对比Chynoweth、van Overstraeten等主流模型的适用场景与精度差异,结合具体案例展示了从几何建模到边界条件设定的完整验证流程,并针对非理想因素提供了有效的补偿技术,助力工程师提升器件仿真的准确性与可靠性。

weixin_29074295的博客 592

QDUOJ 93 - 分辣条(01背包)

分辣条 发布时间: 2016年6月26日 20:36 最后更新: 2016年6月26日 20:37 时间限制: 1000ms 内存限制: 128M描述 “你喝的酸奶是我买的,辣条也是我买的,你现在要跟我分手,你把我当什么?”“因为你每次分辣条的时候都比我多一根!”可见分好辣条是一件多么重要的事情。。现在有n(1<=n<=200)根辣条,每根辣条的重量为a1,a2…ai..an(1<=

Snakeflute的博客 1589

手把手教你用DCA1000和mmWave Studio 2.0采集AWR1843雷达数据(附驱动安装与常见报错排查)

本文详细介绍了使用DCA1000和mmWave Studio 2.0采集AWR1843毫米波雷达数据的全流程指南,包括硬件连接、驱动安装、软件配置及常见报错排查。通过实战经验分享,帮助开发者快速掌握数据采集技巧,优化雷达参数配置,提升数据质量与采集效率。

weixin_30070339的博客 334

HFSS入门 - 传输线线路损耗和串扰仿真

下图中两相近传输线存在端口间的串扰,而同一根传输线存在线路损耗。 我们可用S21描述端口1到端口2的线路损耗(插损?),用S13描述近端串扰,S24描述远端串扰,串扰通常要求-20dB以下。 实验目的:传输线线路损耗和串扰仿真 具体步骤: 1.草图: 其中板厚Subh为1mm。其余参数具体值如下: 2.由草图作图: 其中介质板表面设为GND。 3.设置激励:先在第一根传输线相连的XZ平面上做一...

qq_37274411的博客 9161

QDUOJ 分辣条-01背包恰好装满情况

分辣条 发布时间: 2016年6月26日 20:36 最后更新: 2016年6月26日 20:37 时间限制: 1000ms 内存限制: 128M 描述 “你喝的酸奶是我买的,辣条也是我买的,你现在要跟我分手,你把我当什么?” “因为你每次分辣条的时候都比我多一根!” 可见分好辣条是一件多么重要的事情。。 现在有n(1<=n<=200)根辣条,每根辣条的...

weixin_30349597的博客 256

RK3588设备树调试实战:解决NPU不加载、USB3.0识别异常与DP显示问题

本文深入探讨了RK3588设备树调试中的三大典型问题:NPU不加载、USB3.0识别异常与DP显示问题。通过详细的问题定位步骤、关键设备树修改和调试技巧,帮助开发者快速解决硬件适配中的挑战,提升RK3588平台的开发效率。

weixin_30576827的博客 477

DAG上的动态规划之再次思考(QDUoj分辣条2)

https://qduoj.com/problem/99/ 分辣条2 发布时间: 2016年7月2日 21:47   最后更新: 2016年7月2日 21:51   时间限制: 1000ms   内存限制: 128M 描述 啊啊有根很大的辣条,重量为n,啊啊想把辣条分给很多小朋友,但是必须满足下列条件: 1.每个小朋友分得的辣条重量为a,b或c; 2.分得辣条的

Rain 725

GEE必须会教程——一文教会你研究区域分块计算与合并

一整块算不是挺好的吗?emmmm,用过的人都知道,GEE好比幼年期的“紫妍”,要用“丹药”来养的,除非你是萧炎小友,到哪都有人给爆金币。我们今天想做的是计算2020年夏季西藏自治区的植被覆盖度(FVC),FVC的估算需要使用归一化植被指数(NDVI数据),这里我们用到的产品是MODIS的相关数据产品,该产品的分辨率是25 0m。下载好的结果毕竟是一块一块的,怎么对下载好的结果进行拼接,变成一张大图呢,别急,接下来,我们上科研小霸王——R语言。此处,我们通过省份数据,按照属性筛选,得到西藏自治区的行政边界。

Promising_GEO的博客 2512

基于YOLOv8的表面裂痕等缺陷检测:深度学习与UI界面的实践

本文详细介绍了如何使用YOLOv8进行表面裂痕等缺陷检测,并结合图形用户界面展示检测结果。通过YOLOv8的强大能力,我们可以实现高效、准确的表面缺陷检测,提升工业产品的质量控制水平。未来,随着深度学习技术和数据集的不断发展,表面缺陷检测的精度和速度将不断提升,应用领域也将进一步拓展。希望本文的实践能够为深度学习在工业检测领域的应用提供一些启示。

YOLO 551

数据结构-分数类(一)

分数代表整体的一部分,或更一般的,任何数量化相等的一部分。 分数是一个整数a和一个正整数b的不等于整数的比。 在一般的数值计算中,一般把分数计算为实数表示然后进行计算,但是有些对精度要求特别高的计算过程中,我们就需要用到分数了。 一个简单的小例子,输入分数 a/b , c/b,输出结果 a/b * c/b,要求用输出用分数表示。 输入:整数a,b,c,d 输出:分数相乘的结果。 运行结...

辣条不爱辣的博客 881

128、点云配准与ICP:经典配准算法与深度学习配准

上周调试一台双臂协作机器人,左手持结构光相机扫描桌面上的随机堆叠工件,右手准备执行抓取。问题出在“对齐”这一步——相机扫描得到的点云和CAD模型点云之间差了大约15度的旋转,导致抓取姿态计算出来直接怼到桌面上。我第一反应是“ICP跑一下不就行了”,结果跑了三分钟,误差纹丝不动,甚至越迭代越发散。后来查了日志才发现,初始位姿给得太离谱,ICP直接掉进了局部最优。这个场景太典型了——很多人以为点云配准就是调个ICP库函数,实际工程里坑比想象中多得多。今天这篇笔记,咱们把点云配准这件事从头捋一遍。

sundong_81的博客 46

之江学院2017ACM校赛 Problem B: qwb与矩阵(记忆化搜索)

题意:(n, m)的迷宫,每个点都有一个值,从(1, 1)走到(n, m) 有三种走法:移动到(x+1,y),(x,y+1)或者(x,y*k),其中k>1,问走到(n,m)的最大价值。 思路:和HDU1078很像,记忆化搜索就行。 代码: #include #include #include using namespace std; const int maxn = 25;

CillyB的博客 1605

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

深度学习工具包 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")

Codeforces 366D Dima and Trap Graph(搜索剪枝/二分)

题目地址:点击打开链接 题意:给你一个图,每条边有一个[L, R],只有在这个区间内的点才能通过,问满足能从1 到n的最大连续区间的长度为多少 思路: 二分思路:枚举下界,二分上界,dfs是否能到。 搜索思路: 剪枝1.如果到过该点,并且此时的左右边界比原先的小,剪枝; 剪枝2:如果当前左右边界范围的值比之前搜到的答案还小,剪枝; 二分代码: #i

CillyB的博客 992

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

HDU 5887 Herbs Gathering (超大01背包|dfs+剪枝|map|卡时)

题意:最多100个物品,v和w都 思路: 是个超大01背包。这题有好多做法,学到不少东西。 1.dfs+剪枝:我们可以按性价比排序,若剩下的背包空间都以最高性价比选也比我们已知的ans小,则剪枝。 2.map优化dp,见代码 3.按一定贪心策略把更可能是答案的放前面排序后dfs,运行时间达到一定程度则return if((clock()-startTime)/CLOCKS_PE

CillyB的博客 843

Educational Codeforces Round 22 C. The Tag Game(思维 搜索)

题意:给你一个无向有根树,根节点为1,有两个人,A在节点1,B在节点X,AB轮流走,B先走,每次可以原地不动或是向相邻节点移动一次。A想最快抓到B,B想最慢被抓到, 问什么时候A抓到B。 思路:每个人都走最优,是不会走回头路的(B来回走可以看作在一点不动),那么我们可以先求下A,B分别到所有节点的最短时间,对于每个节点如果B走的时间小于A走的时间那B就可以走到这个,所以找到disB[i

CillyB的博客 816

poj 3321 Apple Tree(dfs标号+树状数组)

很好的一个题,讲一个树通过标号,巧妙的转换成了树状数组。 参考思路:点击打开链接 思路很巧妙,我们通过自己来编号所有苹果,每个节点保存两个值,左值为本身,右值为 其包含的所有后代中最大的编号 我们可以通过搜索来进行编号,在编好号之后,我们可以知道,对于某一点而言,我们是 先通过这个点搜完所有他的后

CillyB的博客 779

lightoj 1174 - Commandos(最短路)

1174 - Commandos     PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB A group of commandos were assigned a critical task. They are to

CillyB的博客 627

2017 Multi-University Training Contest 10 1001 Admiral HDU 6171 (双向搜索 哈希)

题意: 给你一个高度为6的塔形数组,你每次只能将0与他上下相邻的某个数交换,问最少交换多少次可以变为初始状态,若需要的步数大于20,直接输出too difficult,初始状态为: 0  1 1  2 2 2  3 3 3 3  4 4 4 4 4  5 5 5 5 5 5 思路:因为最多走20步,当存搜索时间复杂度4^20, 所以我们可以分别从当前状态和初始状态进行双向

CillyB的博客 615

Codeforces Round #430 (Div. 2) C. Ilya And The Tree(dfs)

题意:给你一棵树,根节点是1,每个节点都有一个权值,现在要求出每个节点的结果,结果的定义为从根节点到该节 点(包含)路径上所有点的值的gcd,求解每个点时可以把路径上某一个点的值变为0。每个节点的结果独立计算。 思路:可以直接进行dfs,每个节点有set分别保存它到根节点不取每一个点的gcd,比如路径为1 - 2 - 3 - 4,4号节点 保存的set是gcd(a[1], a[2],

CillyB的博客 609

hdoj 3345 War Chess (搜索,优先队列)

War Chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2332    Accepted Submission(s): 561 Problem Description War chess is hh's

CillyB的博客 603

hdoj 4198 Quick out of the Harbour(bfs,优先队列)

一个裸的bfs+优先队列,居然还MLE两次,WA两次,哎 MLE:忘记book[tx][ty] = 1了,还找了半天哪里会MLE啊。。。 WA:没考虑到S就在边界的情况。。。 代码: #include using namespace std; const int maxn = 505; int row, col, d, sx, sy; char pic[maxn][

CillyB的博客 590

Gym 101572E Emptying the Baltic(优先队列)

题意:n*m的地图, 每个格子有一个海拔高度, 海拔 思路:从(x,y)开始bfs,扩展到的点v[tu][tv] = max(v[tu][tv], v[u][v])。但是不能用普通的bfs。需要加优先队列。(点 击打开链接)因为水可以往八个方向流, 如果先出队列的不出最深的一个点的话, 原本能流过去的水可能就流不过去 了, 所以用优先队列, 保证先出队列的是当前已处理的最深的节点

CillyB的博客 586

poj 2676 Sudoku (dfs)

解数独..暴搜即可 一开始傻逼的以为没必要把格子还原为0,wa了半天还坚信这不用还原...长记性了。。 还有这题正搜和反搜时间差好多,正搜要400ms反搜只需16ms.... 代码: #include #include #include using namespace std; char tpic[15][15]; int pic[15][15], book_row

CillyB的博客 557

HDU 5094 Maze & HDU 4845 拯救大兵瑞恩 (BFS + 状压)

题意:给你一个n*m的迷宫,地图中有一些障碍不能走,还有p种门,要过门首先得拿到跟这扇门同类型的钥匙。 问从(1,1)到(n,m)最短时间。(1 思路:没有门的时候都会做,一个bfs就行,现在只不过是多了门这种情况。 解决办法: book[x][y][sta] 表示(x, y)这个点在sta状态下是否已经走过,sta表示拥有钥匙情况。 bar[x1][y1][x2][y2] 表示

CillyB的博客 541
上一篇: qduoj 分辣条2(完全背包,装满问题)
下一篇: poj 1661 Help Jimmy(dp)
cillyb
博客等级 码龄11年 225粉丝 497原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值