http://poj.org/problem?id=3414

 #include <iostream>
#include <cstdio>
#include <queue>
#include <cstring> using namespace std; struct node{
int first;
int second;
int opera[];
int cou;
};
queue<node> que;
int vis[][]; //opera数组数据意义
//fill(1) 110----120
//drop(1) 210----220
//pour(1,2) 312----321
//三位数分别表示操作,第一个参数,第二个参数 node bfs(int a,int b,int c){
node ff;
ff.first=;
ff.second=;
ff.cou=;
que.push(ff);
node t;
memset(vis,,sizeof(vis));
while(!que.empty()){
node f=que.front();
que.pop();
if(f.first==c||f.second==c){
return f;
}
t=f;
t.first=a;
t.opera[t.cou++]=;
if(vis[t.first][t.second]!=){
que.push(t);
}
vis[t.first][t.second]=; t=f;
t.first=;
t.opera[t.cou++]=;
if(vis[t.first][t.second]!=){
que.push(t);
}
vis[t.first][t.second]=; t=f;
int l=b-t.second;
if(t.first>=l){
t.second=b;
t.first-=l;
}else{
t.second+=t.first;
t.first=;
}
t.opera[t.cou++]=;
if(vis[t.first][t.second]!=){
que.push(t);
}
vis[t.first][t.second]=; t=f;
t.second=b;
t.opera[t.cou++]=;
if(vis[t.first][t.second]!=){
que.push(t);
}
vis[t.first][t.second]=; t=f;
t.second=;
t.opera[t.cou++]=;
if(vis[t.first][t.second]!=){
que.push(t);
}
vis[t.first][t.second]=; t=f;
l=a-t.first;
if(t.second>=l){
t.first=a;
t.second-=l;
}else{
t.first+=t.second;
t.second=;
}
que.push(t);
vis[t.first][t.second]=;
}
} int main()
{
int a,b,c;
while(~scanf("%d %d %d",&a,&b,&c)){
if(a==b&&b==c){
printf("1\n");
printf("FILL(1)\n");
continue;
}else if(a==b&&b!=c||c>a&&c>b){
printf("impossible\n");
continue;
}
node ans=bfs(a,b,c);
printf("%d\n",ans.cou);
for(int i=;i<ans.cou;i++){
int baiwei=ans.opera[i]%;
int shiwei=ans.opera[i]/%;
int gewei=ans.opera[i]%;
if(baiwei==){
if(shiwei==){
printf("FILL(%d)\n",);
}else{
printf("FILL(%d)\n",);
}
}else if(baiwei==){
if(shiwei==){
printf("DROP(%d)\n",);
}else{
printf("DROP(%d)\n",);
}
}else if(gewei==){
printf("POUR(%d,%d)\n",shiwei,gewei);
}
}
}
return ;
}

这个代码有毒,没法调试啊

POJ 3414 pots (未解决)的更多相关文章

  1. BFS POJ 3414 Pots

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

  2. 广搜+输出路径 POJ 3414 Pots

    POJ 3414 Pots Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13547   Accepted: 5718   ...

  3. POJ 3414 Pots(罐子)

    POJ 3414 Pots(罐子) Time Limit: 1000MS    Memory Limit: 65536K Description - 题目描述 You are given two po ...

  4. poj 3414 Pots 【BFS+记录路径 】

    //yy:昨天看着这题突然有点懵,不知道怎么记录路径,然后交给房教了,,,然后默默去写另一个bfs,想清楚思路后花了半小时写了120+行的代码然后出现奇葩的CE,看完FAQ改了之后又WA了.然后第一次 ...

  5. poj 3414 Pots【bfs+回溯路径 正向输出】

    题目地址:http://poj.org/problem?id=3414 Pots Time Limit: 1000MS   Memory Limit: 65536K Total Submissions ...

  6. POJ 3414 Pots

    Pots Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status  ...

  7. POJ 3414 Pots【bfs模拟倒水问题】

    链接: http://poj.org/problem?id=3414 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22009#probl ...

  8. poj 3414 Pots(广搜BFS+路径输出)

    转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:id=3414">http://poj.org/probl ...

  9. poj 3414 Pots ( bfs )

    题目:http://poj.org/problem?id=3414 题意:给出了两个瓶子的容量A,B, 以及一个目标水量C, 对A.B可以有如下操作: FILL(i)        fill the ...

随机推荐

  1. CentOS使用Ubuntu的start-stop-daemon来启动守护进程

    在CentOS下使用守护进程启动有/etc/init.d/functions文件下的daemon方法,但如果要使用Ubuntu下的start-stop-daemon方法也可以实现. 安装如下: # 下 ...

  2. PowerBI发布到网页

    如果网页当中需要嵌入PowerBI的报表,可以在PowerBI当中生成链接,然后网页或者博客当中插入这一段html代码. 以下是PowerBI生产网页链接的示例,并且在博客的最后也插入了PowerBI ...

  3. 用C++实现半透明按钮控件(PNG,GDI+)

        使用MFC实现上面的按钮半透明效果能看到父窗口中的内容,上面是效果图(一个是带背景图片的.另一个是不带的). 控件继承自CWnd类(彩色的部分是窗口的背景图片.按钮是PNG图片,第二个图标是鼠 ...

  4. SpringBoot无废话入门02:SpringBoot启动分析

    1.核心注解 在上文中,我们讲到了@SpringBootApplication是SpringBoot的核心注解. 可以很方便的在idea中下载源码来查看该注解的源码,如下: 可以看到,该注解本身又被其 ...

  5. Go语言之高级篇beego框架之日志收集系统

    一.日志收集系统架构设计 图1 图2 二.开发环境 1.安装jdk jdk-8u51-windows-x64.exe 安装目录:C:\Program Files\jdk8 2.安装zookeeper ...

  6. CSAPP Tiny web server源代码分析及搭建执行

    1. Web基础 webclient和server之间的交互使用的是一个基于文本的应用级协议HTTP(超文本传输协议). 一个webclient(即浏览器)打开一个到server的因特网连接,而且请求 ...

  7. __NSArrayI __NSArray0 __NSSingleObjectArrayI __NSPlaceholderArray __NSArrayM

    如果你的 全局 可变数组 前面  用了  copy修饰,那么 调用   arr addObjectsFromArray: 的时候 就 会崩溃,而且提示你  是  [__NSArray0 addObje ...

  8. 1、金融之关于BIAS

    一.☆BIAS(1)什么是BIAS☆ BIAS[指标介绍]      BIAS乖离率也称为Y值,是用股价指数与移动平均线的比值关系,来描述股票价格与移动平均线之间的偏离程度.乖离率功能主要是通过测算股 ...

  9. 记一次spring boot参数初始化的问题

    背景:接手一个项目,看到一个配置参数的引用: @Value("${webSocket.id}") 再看看配置application.yml: ... webSocket: id: ...

  10. thymeleaf th:href 多个参数传递格式

    今天在使用thymeleaf的th:href传递多个参数的时候困惑了.然后百度了一下,发现没有人注释说明怎么弄,然后自己google了一下,现在就标记一下,方便记录一下. th:href=" ...