poj 3414(简单bfs)】的更多相关文章

题目链接:http://poj.org/problem?id=3414 思路:bfs简单应用,增对瓶A或者瓶B进行分析就可以了,一共6种状态. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> using namespace std; struct Node{ int a,b,step; ][]; }; int A,B…
Pots(POJ - 3414) 题目链接 算法 BFS 1.这道题问的是给你两个体积分别为A和B的容器,你对它们有三种操作,一种是装满其中一个瓶子,另一种是把其中一个瓶子的水都倒掉,还有一种就是把其中一个瓶子的水导入另一个瓶子中(可能会有剩余).最后让你输出在能够得出体积为C的水的情况下操作的最小次数并且把过程输出.如果无法得出体积为C的水,则输出"impossible". 2.这个题主要涉及两个点,一个是求出最小次数,还有一个就是把路径输出.对于这种有目标值的求最小次数问题,我们可…
题目: http://poj.org/problem?id=3414 很好玩的一个题.关键是又16ms 1A了,没有debug的日子才是好日子.. #include <stdio.h> #include <string.h> #include <queue> #include <algorithm> #include <stack> using namespace std; int a, b, c; ][]; enum Ways{FILL_A,…
#include<iostream> #include<cstring> #define fillA 1 #define pourAB 2 #define dropA 3 #define fillB 4 #define pourBA 5 #define dropB 6 #define N 10000 using namespace std; ][]; class node { public: int A, B; int dir; node() { A=; B=; } }; int…
The Game 题意: Description One morning, you wake up and think: "I am such a good programmer. Why not make some money?" So you decide to write a computer game. 一天清晨,你起床后想到:"我是一个这么牛的程序员,为什么不赚点钱呢?"所以,你决定写一个电脑游戏. The game takes place on a re…
题意: 给你两个空瓶子,只有三种操作 一.把一个瓶子灌满 二.把一个瓶子清空 三.把一个瓶子里面的水灌到另一个瓶子里面去(倒满之后要是还存在水那就依然在那个瓶子里面,或者被灌的瓶子有可能没满) 思路:BFS,打印路径时需技巧. //G++ 840K 0MS #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <stack> #in…
Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu 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…
题意:给定农夫和奶牛的初始位置,农夫可以当前位置+1.-1.*2三种移动方式,问最少需要多少分钟抓住奶牛 AC代码: #include<cstdio> #include<cstring> #include<queue> using namespace std; const int maxn=100000+5; const int dx[]={-1,1,2}; int d[maxn]; int n,k; int bfs(){ queue<int>q; mems…
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 from…
Pots 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 from pot i …