POJ3414(BFS)

【代码超详解】POJ 3414 Pots(BFS,0 ms) 一、题目描述 Pots Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 29772 Accepted: 12428 Special Judge Description You are given two pots, having the volume of A and B liters respectively. The ... 阅读详情

POJ3414(BFS)


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) pour from pot i to pot j; after this operation either the pot j is full (and there may be some water left in the pot i), or the pot i is empty (and all its contents have been moved to the pot j).

Write a program to find the shortest possible sequence of these operations that will yield exactly C liters of water in one of the pots.

Input

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

Output

The first line of the output must contain the length of the sequence of operations K. The following K lines must each describe one operation. If there are several sequences of minimal length, output any one of them. If the desired result can’t be achieved, the first and only line of the file must contain the word ‘impossible’.

Sample Input

3 5 4

Sample Output

6
FILL(2)
POUR(2,1)
DROP(1)
POUR(2,1)
FILL(2)
POUR(2,1)
题意

​ 给出两个壶的容量A和B, 一个目标水量C,对A、B可以有3种操作,求最少经过几步操作能够在某个壶中得到目标水量C。输入A、B和C,输入最少操作数和操作过程。不可能则输出impossible。

  • FILL(i),将i水壶的水填满
  • DROP(i),将水壶i中的水全部倒掉
  • POUR(i,j)将水壶i中的水倒到水壶j中,若水壶 j 满了,则 i 剩下的就不倒了
思路

​ BFS搜索两个水壶A、B的状态,初始状态为<0,0>,搜索的方向是对应的六种操作。最终要输出操作的过程,即需要记录搜索的路径,需要在每个节点中记录父节点的信息。

代码
public class Pots {

    int a;
    int b;
    int c;
    List<Node> queue = new ArrayList<Node>();//队列
    int[][] visit = new int[200][200];//记录某种状态是否已经达成过

    int lastStepIndex;//最后一步的在队列中的下标

    boolean flag = false;//是否成功

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Pots pots = new Pots();
        pots.a = sc.nextInt();
        pots.b = sc.nextInt();
        pots.c = sc.nextInt();
        pots.bfs();
        if (pots.flag) {
            List<Integer> result = new ArrayList<Integer>();
            int index = pots.lastStepIndex;
            while (true) {
                if (index == -1) {
                    break;
                }
                result.add(pots.queue.get(index).getLayer());
                index = pots.queue.get(index).pre;
            }
            System.out.println(result.size() - 1);
            for (int i = result.size() - 1; i >= 0; i--) {
                switch (result.get(i)) {
                    case 0:
                        System.out.println("FILL(1)");
                        break;
                    case 1:
                        System.out.println("FILL(2)");
                        break;
                    case 2:
                        System.out.println("DROP(1)");
                        break;
                    case 3:
                        System.out.println("DROP(2)");
                        break;
                    case 4:
                        System.out.println("POUR(1,2)");
                        break;
                    case 5:
                        System.out.println("POUR(2,1)");
                        break;
                }
            }
        } else {
            System.out.println("impossible");
        }
    }

    public void bfs() {
        Node node = new Node();
        node.setA(0);//初始状态a
        node.setB(0);//初始状态b
        node.setLayer(-1);
        node.setPre(-1);
        queue.add(node);
        int rear = 1;//队尾
        int front = 0;//队头
        while (front < rear) {
            Node now_Node = queue.get(front);
            front++;//出队列
            if (now_Node.getA() == c || now_Node.getB() == c) {
                flag = true;
                lastStepIndex = front - 1;
            }
            for (int i = 0; i < 6; i++) {//遍历6中操作
                Node next = new Node();
                if (i == 0) {//fill(1)
                    next.setA(a);
                    next.setB(now_Node.getB());
                } else if (i == 1) {//fill(2)
                    next.setA(now_Node.getA());
                    next.setB(b);
                } else if (i == 2) {//drop(1)
                    next.setA(0);
                    next.setB(now_Node.getB());
                } else if (i == 3) {//drop(2)
                    next.setA(now_Node.getA());
                    next.setB(0);
                } else if (i == 4) {//pour(1,2)
                    if (now_Node.getA() + now_Node.getB() <= b) {//把A水壶的水倒入B,不能装满B
                        next.setA(0);
                        next.setB(now_Node.getA() + now_Node.getB());
                    } else {//把A水壶的水倒入B,能装满B
                        next.setA(now_Node.getA() + now_Node.getB() - b);
                        next.setB(b);
                    }
                } else if (i == 5) {//pour(2,1)
                    if (now_Node.getA() + now_Node.getB() <= a) {
                        next.setA(now_Node.getA() + now_Node.getB());
                        next.setB(0);
                    } else {
                        next.setA(a);
                        next.setB(now_Node.getA() + now_Node.getB() - a);
                    }
                }
                next.setLayer(i);
                next.setPre(front - 1);
                if (visit[next.getA()][next.getB()] == 0) {//当前状态没有进入过队列
                    visit[next.getA()][next.getB()] = 1;//标记次状态已经进入队列
                    queue.add(next);//进入队列
                    rear++;//队尾延长

                    if (next.getA() == c || next.getB() == c) {//达成目标
                        flag = true;
                        lastStepIndex = rear - 1;
                        return;
                    }
                }
            }
        }
    }

    static class Node {
        private int layer;//表示第几种操作。
        private int a;//a水壶的水量
        private int b;//b水壶的水量
        private int pre;//上一步操作的index

        public int getA() {
            return a;
        }

        public void setA(int a) {
            this.a = a;
        }

        public int getB() {
            return b;
        }

        public void setB(int b) {
            this.b = b;
        }

        public int getLayer() {
            return layer;
        }

        public void setPre(int pre) {
            this.pre = pre;
        }

        public int getPre() {
            return pre;
        }

        public void setLayer(int layer) {
            this.layer = layer;
        }
    }
}
poj 3414解题报告 poj 3414解题报告poj 3414解题报告poj 3414解题报告poj 3414解题报告 立即下载

相关推荐

POJ3414-Pots

北大POJ3414-Pots 解题报告+AC代码

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

STM32F103串口接收中断:USART_IT_IDLE和USART_IT_RXNE区别

2:如果是大于1个byte的数据,在不用DMA的情况下,同时使能USART_IT_RXNE,USART_IT_IDLE中断,每收到一个字节在中断中把数据存到缓存中,待收到USART_IT_IDLE中断时,收完整帧数据,然后再解析处理数据。比如:如上图在初始化时,同时开启了两个中断,如果传送8个字节的数据,就会产生8个USART_IT_RXNE,和1个USART_IT_IDLE中断。(如果接收到数据,在1个byte的时间内,没有收到新数据,就认为是数据传送完成,产生空闲USART_IT_IDLE中断)

weixin_66299220的博客 2399

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

在 Ansys CFX Pre 中配置 RGP 表的分步指南

掌握在 Ansys CFX Pre 中设置 RGP 表的技巧,以优化仿真精度和效率。

jkh920184196的博客 1664

Xcelium XRUN实用指南:从入门到高效仿真

本文是Xcelium XRUN仿真工具的实用指南,从基础入门到高效应用全面解析。XRUN作为Cadence Xcelium的统一命令行入口,能自动化编译、精细和仿真流程,大幅提升数字芯片与FPGA验证效率。文章详细介绍了最简命令、波形调试、增量编译、多核并行仿真等核心功能,并提供了管理复杂项目、性能调优与深度调试的进阶技巧,帮助工程师快速上手并精通这一高效仿真工具。

weixin_29238147的博客 740

BFS学习笔记-POJ3414 Pots 双桶取水问题

BFS自学笔记,简要地解释了记录BFS操作的方法和BFS的要点

ex_voda的博客 711

手把手教你解决Realsense D455在ROS下IMU数据不输出的问题(附固件降级指南)

本文详细解析了Realsense D455在ROS环境下IMU数据不输出的问题,提供了固件降级和ROS配置的完整解决方案。通过版本兼容性分析和实战操作指南,帮助开发者快速恢复IMU数据流,优化机器人开发体验。

weixin_42531494的博客 372

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

bfs,poj

曾经追梦的happy时光 935

S7-1200与KINCO伺服通信实战:CM CANopen模块配置避坑指南(附完整PDO映射表)

本文详细解析了西门子S7-1200 PLC通过CM CANopen模块与KINCO伺服驱动器的通信配置全流程,重点解决PDO映射混乱、心跳报文配置错误等常见问题。提供硬件组态、参数设置、PDO映射模板及故障排查方案,助力工业自动化系统实现稳定高效的多轴运动控制。

2y3u4i5o6p的博客 1101

YOLOv11改进 - 卷积Conv | SPD-Conv空间深度转换卷积优化空间信息编码,攻克小目标检测难题

本文介绍了一种名为SPD-Conv的新型CNN构建块及其在YOLOv11中的结合。传统CNN在处理低分辨率图像或小物体时,因使用步长卷积和池化层导致细粒度信息丢失、性能下降。SPD-Conv由空间到深度(SPD)层和非步长卷积(Conv)层组成,完全消除卷积步长和池化层,避免信息损失。SPD层重排特征图元素将空间信息转换到深度维度,非步长卷积层进一步处理特征图。我们将SPD-Conv集成进YOLOv11,实验证明其在低分辨率图像和小物体检测任务上显著优于现有模型。

魔改工程师的博客 1141

POJ-3414:Pots(BFS+特殊标记+递归回溯输出路径)

POUR(i,j):将第 i 个容器里的水倒入第 j 个容器(这次操作结束后产生两种结果,一是第j 个容器倒满并且第 i 个容器依旧有剩余,二是第 i 个容器里的水全部倒入 j 中,第 i 个容器为空);,BFS找终点和步骤数那倒是没问题,可是怎么输出路径呢,每一步都可能不止一种选择合法啊,不到最后不知道那条路才是通往终点的啊。有且只有一行,包含 3 个数A,B,C(1≤A,B≤100,C≤max(A,B))。FILL(i):将第 i 个容器从水龙头里装满(1≤i≤2);那么话不多说,这里直接贴代码了。

weixin_65039404的博客 350

使用 FastAPI 和 LangGraph 构建生产级智能体 AI 系统

这是一本关于使用 FastAPI 和 LangGraph 构建生产级智能体 AI 系统的详细书籍,全文约 10 万字。《Production-Grade Agentic AI System Design and Implementation: Building Agentic AI Systems Using FastAPI and LangGraph》随着人工智能(AI)技术的迅猛发展,智能体(Agent)作为能够自主感知、推理、决策和行动的实体,正逐渐成为构建复杂智能系统的核心。从个性化推荐、客户服务到

AI天才研究院 347

【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

基于网关实现不同网段S7-1200 CPU的通信方法

在A网段的计算机上ping B网段的计算机:在A网段的计算机上使用ping命令,向B网段的计算机发送数据包。在B网段的计算机上ping A网段的计算机:同样地,在B网段的计算机上使用ping命令,向A网段的计算机发送数据包。数据包也会经过路由器进行转发,最终到达A网段的计算机。配置路由器:在路由器上配置两个网段的IP地址和子网掩码,并设置路由表,使得路由器可以将A网段和B网段之间的数据进行转发。确定两个网络之间的路由器:假设需要将A网段和B网段进行通信,需要在A、B两个网段之间设置一台路由器。

电工 2399

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

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

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

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

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

POJ 3414 Pots【BFS水】

POJ 3414 Pots大意:有两只桶,容量分别为a,b,对每只桶,有以下三种操作:1.Fill(i)装满第i只桶2.DROP(i)将桶i的水倒掉3.POUR(i,j),将桶i中的水倒入桶j,若桶j满,剩余的水遗留于桶i中 问能否通过这些操作使得某只桶恰好装有容量为c的水?若能,输出最少操作次数及过程PS:c<max(a,b); 算法:BFS即可 #include&...

a48634331的博客 149

BFS POJ 3414 Pots

题目传送门 1 /* 2 BFS:六种情况讨论一下,BFS轻松解决 3 起初我看有人用DFS,我写了一遍,TLE。。还是用BFS,结果特判时出错,逗了好长时间 4 看别人的代码简直是受罪,还好自己终于发现自己代码的小错误:) 5 */ 6 /***************************************...

weixin_30237281的博客 57

poj 3414 Pots 【BFS+记录路径 】

//yy:昨天看着这题突然有点懵,不知道怎么记录路径,然后交给房教了,,,然后默默去写另一个bfs,想清楚思路后花了半小时写了120+行的代码然后出现奇葩的CE,看完FAQ改了之后又WA了。然后第一次用对拍去找特殊数据折腾到十二点半终于AC,最后只想感叹没有仔细读题,没办法啊看着英语略烦躁,不扯了,那个题题解不想写了,回到这题。。。今天中午还是花了四十分钟写了这题(好慢啊orz),感觉,...

dhe56357的博客 152

倒水(BFS)Pots POJ - 3414

Pots POJ - 3414 题目链接 bfs题; 标注的状态应为2容器的体积,因为每种2容器的体积都应该只由一种状态达到。 不使用队列 #include<stdio.h> #include<string.h> struct node{ int now_x; int now_y; int step; int howcome; int before; }ll[10050];...

qq_43559193的博客 262

poj 3414 bfs水题但是麻烦

啦啦啦,这个太刷成就感了!!!!115行代码哦 poj 3414原题戳这大致题意: 给你容器a,容器b,还有容量c; 问你是否能够通过有限的步骤达到c的目标状态呢?嗯,关于path数组其实又参看大神的,不得不说太腻害了 操作6种: 1.装满a FILL(1) 2.装满b FILL(2) 3.清空a DROP(1) 4.清空b DROP(2) 5.把A倒入B POUR(1,2) (

mars_ch的博客 434

POJ 3414 Pots (BFS/DFS)

Pots Time Limit:1000MS Memory Limit:65536K Total Submissions:7783 Accepted:3261 Special Judge Description You are given two pots, having the volume ofA...

airen6935的博客 190

H - Pots POJ - 3414(倒水问题+BFS回溯)

H - Pots POJ - 3414 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(...

石旭先森的博客 482

POJ - 3414 Pots BFS + 记录并输出路径

POJ - 3414 Pots 题意: 给你两个杯子的容量 和 最后杯子中剩余水的容量。有三种操作方式 FILL(i)        将第 i 个杯子装满水 DROP(i)      将第 i 个杯子的水倒空  POUR(i,j)     将第 i 个杯子中的水倒入第 j 个杯子中     可能有两种情况:(1) i 杯子中的水还没全倒入 j 杯子中 j 杯子就满了,此时 i 杯子中还...

没有梦想何以远行 272
上一篇: POJ2251(BFS)
下一篇: POJ3984(BFS)
shui2104
博客等级 码龄10年 22粉丝 104原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值