poj 3414

poj 3414解题报告 poj 3414解题报告poj 3414解题报告poj 3414解题报告poj 3414解题报告 立即下载

#include<iostream>
#include<queue>
#include<cstring>
#include<string>
#include<cstdio>
using namespace std;
const int maxn = 100 + 10;
int A,B,C;
int vis[maxn][maxn];
struct node{
    int a,b,step;
    char str[111][111];
};
bool bfs(){
    queue<node>qq;
    memset(vis,-1,sizeof(vis));
    node tmp;
    tmp.a=0,tmp.b=0,tmp.step=0;
    qq.push(tmp);
    vis[0][0]=1;
    while(!qq.empty()){
        tmp=qq.front();
        qq.pop();
        node t;

        if(tmp.a==C||tmp.b==C){
                printf("%d\n",tmp.step);
            for(int i=1;i<=tmp.step;i++)printf("%s\n",tmp.str[i]);
            return true;
        }



        //1
        t=tmp;
        t.a=0;
        t.b=tmp.b;
        t.step=tmp.step+1;
        strcpy(t.str[t.step],"DROP(1)");
        if(vis[t.a][t.b]==-1){
            vis[t.a][t.b]=1;
            qq.push(t);
        }


        //2
        t=tmp;
        t.b=0;
        t.a=tmp.a;
        t.step=tmp.step+1;
        strcpy(t.str[t.step],"DROP(2)");
        if(vis[t.a][t.b]==-1){
            vis[t.a][t.b]=1;
            qq.push(t);
        }





         //3
        t=tmp;
        t.a=A;
        t.b=tmp.b;

        t.step=tmp.step+1;
        strcpy(t.str[t.step],"FILL(1)");
        if(vis[t.a][t.b]==-1){
            vis[t.a][t.b]=1;
            qq.push(t);
        }




        //4
        t=tmp;
        t.a=tmp.a;
        t.b=B;
        t.step=tmp.step+1;
        strcpy(t.str[t.step],"FILL(2)");
        if(vis[t.a][t.b]==-1){
            vis[t.a][t.b]=1;
            qq.push(t);
        }

        //5
        t=tmp;
        t.a=min(A,tmp.a+tmp.b);
        t.b=tmp.a+tmp.b-t.a;
        t.step=tmp.step+1;
        strcpy(t.str[t.step],"POUR(2,1)");
        if(vis[t.a][t.b]==-1){
            vis[t.a][t.b]=1;
            qq.push(t);
        }




        //6
        t=tmp;
        t.b=min(B,tmp.a+tmp.b);
        t.a=tmp.a+tmp.b-t.b;
        t.step=tmp.step+1;
        strcpy(t.str[t.step],"POUR(1,2)");
        if(vis[t.a][t.b]==-1){
            vis[t.a][t.b]=1;
            qq.push(t);
        }

    }
    return false;
}
int main(){

    while(~scanf("%d%d%d",&A,&B,&C)){
        if(!bfs())printf("impossible\n");

    }
}

这个题不算难

分六个状态讨论就行了

直接上代码

POJ3414-Pots 北大POJ3414-Pots 解题报告+AC代码 立即下载

相关推荐

poj刷题指南

网上整理的一些poj刷题指南。 poj地址:http://poj.org

POJ【3414】Pots(倒水问题+打印路径)

题目链接:http://poj.org/problem?id=3414 分析 这道题属于倒水问题,思想不变,不过在此之上还需要打印路径,需要在节点当中存储操作o,还需要记录每一个节点的父亲。 #include<iostream> #include<cstdio> #include<cstring> #include<queue> #include<vector> using namespace std; const int N = 100 + 10

yj8023xx的博客 448

【银河麒麟服务器】银河麒麟V10 SP3高级服务器操作系统网卡配置完全指南:图形界面、Network、NetworkManager、IP 地址、路由与端口聚合详解

本文系统介绍了银河麒麟V10SP4服务器操作系统的网络配置方法,涵盖图形界面、NetworkManager、nmcli命令行等多种配置方式。重点讲解了IP地址设置、路由管理以及端口聚合(Bonding)的实现,包括传统配置文件、nmcli和nmtui三种Bonding配置方案。文章对比了NetworkManager与传统network服务的区别,并提供了常见网络问题的排查建议。通过多种配置方法的详细说明,帮助用户掌握银河麒麟服务器系统的网络管理技能,构建稳定可靠的网络环境。

YHLCCY的博客 5388

POJ - 3414(BFS+链表)

1. node *pre; 用前向链表存储上一位的状态 2. q.push(node(a1, b1, &amp;Node[cnt], i, t.step + 1)); 要用已经定了位置的作为地址,不要用临时变量的地址,临时变量的地址检索不到,会出错。 #include &lt;iostream&gt; #include &lt;queue&gt; #include &lt;cstdio...

Ema1997的博客 297

使用Dify打造视频生成工作流:从提示词到视频的完整指南

Dify作为开源LLM应用开发平台,通过可视化工作流编排实现从文本到视频的端到端生成,将创意周期从天级缩短至分钟级。核心流程包括提示词工程、视频API调用、存储分发和结果反馈。

牛奶夹心巧克力 3435

【实战指南】RF-DETR多场景部署:从工业质检到自动驾驶的SOTA模型应用

本文深入解析了SOTA目标检测模型RF-DETR在工业质检与自动驾驶等多场景下的实战部署指南。该模型基于Transformer架构,在COCO数据集上实现了实时检测与高精度的突破,并凭借其强大的泛化能力,在RF100-VL等复杂数据集上表现出色。文章提供了从快速Demo、工业缺陷检测微调、车载自适应部署到多硬件平台性能优化的完整解决方案,帮助开发者高效应用这一先进模型。

weixin_29070861的博客 475

【poj 3414】Pots 题意&题解&代码(C++)

bfs,poj

曾经追梦的happy时光 935

CASS3D实战:高效三维房屋与地形采集绘制技巧

本文详细介绍了CASS3D在三维房屋与地形采集绘制中的高效技巧,包括智能绘房功能、不规则结构处理、特殊构件快速绘制及地形数据采集策略。通过实战案例和进阶操作指南,帮助用户快速掌握CASS3D的核心功能,提升三维采集与绘制效率。

weixin_29216049的博客 868

POJ 3414(BFS建树)

这一题是典型的BFS建树的问题。首先,可选的操作只有FILL,DROP,POUR三种,而这三种又各自衍生出两个分类。那么,我们可以通过这6种操作不断地转换状态。而我们知道,已经得到过得状态再次得到时,就一定会产生圈,得不到最优解。所以利用一个数组储存看这个状态是否已经达到。       对于每一个子状态,枚举所有的操作,将操作过后得到的新状态压进队列。同时储存得到状态的时间和方法。并且更新这棵树

aaron_1996的专栏 616

BIM Revit教程(六)尝试安装 Revit 时显示“Autodesk Revit 已安装。”

在安装Revit或RevitLT时,若系统提示“AutodeskRevit版本已安装”,通常是由于旧版本残留文件未完全清除所致。解决方案包括:1.通过控制面板或Windows设置卸载旧版本Revit,确保所有相关组件被移除;2.使用Autodesk卸载工具(AdskUninstallHelper)进一步清理;3.谨慎操作注册表,删除与Revit相关的残留项;4.确保系统有至少30GB的可用磁盘空间;5.完成上述步骤后,重新尝试安装Revit。此外,文章还提到了一个免费功能商店,供用户寻找提效工具,并鼓励粉丝

ZOZO_888的博客 2129

CloudCompare 二次开发(36)——非均匀体素降采样

使用CloudCompare与PCL编程实现的非均匀体素降采样。

点云侠的博客 746

POJ3414

POJ3414pots 这些bfs题都很妙啊,多做做肯定有好处的 思路: 每到一次可以作为一个方向,总共有6种方向 ①把A装满 ②把B装满 ③把A倒了 ④把B倒了 ⑤把A倒入B ⑥把B倒入A 其实就是bfs,每次操作先看看是否到达过,然后标记,然后顺着找。总共三个数(100以内),能有多少种组合? 直接用二维数组就可以 #include <iostream> #include<c...

qq_43450892的博客 656

雷达参数的设置

采样率又可以叫做采样速率或者,顾名思义就是每秒采集的次数。该值越高,单位时间内对信号的采集越多,采样率的单位可以用Hz或者sps表示(sps是采样率,是每秒采样点的数量,sp表示采样点数),一般1sps=1Hz。采样时间是采样点数和采样周期的乘积得到的结果。假设实际采样率为4560ksps,采样点数为256,那么采样周期为1/4560(ms),那么ADC的采样时间就为256*(1/4560)(ms)=0.056ms=56微秒。

qq_50974341的博客 1912

POJ 3414 Pots

poj 3414 Pots Description You are given two pots, having the volume of A and B liters respectively. The following operations can be performed: FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap; D...

指弹键盘哼民谣 908

SAP RAP学习系列合集介绍

《SAP RAP学习系列合集:从入门到部署的完整指南》摘要: 本文介绍了作者创建的SAP RAP学习系列合集,涵盖RAP开发从基础概念到实战部署的全流程。系列目前包含17篇文章,系统讲解了RAP核心开发技术:从数据建模、UI构建到行为定义(包括并发控制、草稿功能、授权验证等),最后详细演示了应用部署到Fiori Launchpad的两种方案(OP版和ES版)。

DeveloperMrMeng的博客 1492

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

POJ3414(BFS)

POJ3414(BFS) Pots Description You are given two pots, having the volume of A and B liters respectively. The following operations can be performed: FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap; DROP(i) empty the pot i to the drain; POUR(i,j) pour

shui2104的博客 238

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

POJ 3414 Pots(水壶)

题目链接:POJ 3414 题意: 给两个容量分别为A,B的水壶,标号为1和2,初始水量都是0。每次操作有如下三种选择: ①FILL(i),将i水壶灌满(i=1或2) ②POUR(i),将i水壶中水倒完(i=1或2) ③DROP(i,j)。从i水壶倒水进j水壶,将j水壶倒满或i水壶中水倒完。 问能否经过若干次操作,使得其中一个水壶中的水量是C? 如果能,输出操作次数,以及操作历程

ramay7 628

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

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

poj3414 Pots--BFS

题目来源: poj 3414 问题描述 有两个空壶,最终要将其中一个壶装水量达到给定值。对壶有3种操作方式,一是开水龙头装满,二是倒光,三是将其中一个壶的水倒到另一个壶里,且水倒光或者另一个壶装满。若能实现目标则输出最小步骤数且按顺序输出操作,若不能实现,则输出“impossible” 未AC…之后再看 #include <iostream> #include <queue&gt...

圣托里尼的日落啊~的博客 337

POJ 3414 Pots(bfs、简单但繁琐)

POJ 3414 Pots Description You are given two pots, having the volume of A and B liters respectively. The following operations can be performed: 1.FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap; 2.DROP(i) empty the pot i to the drain; 3.POUR(i,j

Zhengyangxinn的博客 204

【POJ 3414 --- Pots】BFS

【POJ 3414 --- Pots】BFS 题目来源:点击进入【POJ 3414 — Pots】 Description You are given two pots, having the volume of A and B liters respectively. The following operations can be performed: FILL(i) fill t...

来日浅谈的博客 521

POJ_3414_(BFS枚举)

POJ 3414 给两个杯子的容量,还有一个数代表最终容量,和6种操作,求出通过6中操作后 使得任意一个 杯子的容量等于最终容量,输出步数和操作的过程(保存bfs的路径), 用1~6代表每个6中操作,存在结构体中,bfs枚举6中操作,vis[i][j]存杯子中水容量的状态, DROP(i),如果i杯子为空,没有意义,POUR(a,b)根据杯子的大小来决定, #include <queue...

_llc的博客 177

POJ3414 Pots —— BFS + 模拟

题目链接:http://poj.org/problem?id=3414 Pots Time Limit:1000MS Memory Limit:65536K Total Submissions:18550 Accepted:7843 Special Judge ...

alince20008的博客 122

POJ_3414_BFS pots

/* * POJ_3414_BFS * I really like this bfs problem * On the first and only line are the numbers A, B, and C. These are all integers in the range from 1 to 100 and C≤max(A,B). */ #include ...

anchang7456的博客 148

poj 3414 Pots

http://poj.org/problem?id=3414会的题一定要细心此题只有一组测试数据如果你按多组来 加上while(scanf("%d%d%d",&A,&B,&C)!=EOF)多组输入的语句 他会给你个Output Limit Exceeded#include<iostream> #include<string> #include&l...

weixin_30537391的博客 62

POJ 3414 Pots(bfs)

Pots

Pandora_heart的博客 336
上一篇: poj 3126
下一篇: 无向图欧拉回路的判定
is_it_a_error
博客等级 码龄11年 1粉丝 31原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值