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. 7、js对象

    在python中我们学习了面向对象,javascript也是一门面向对象语言,在JavaScript中除了null和undefined以外其他的数据类型都被定义成了对象. 本篇导航: String对象 ...

  2. wireshark解析自定义的protobuf协议

    先看最终效果 wireshark是开源的,而且在Windows下安装时用的是64位,所以相应的库文件需要使用64位. 一个Lua插件的Dissector结构大致如下: do -- 协议名称为 m_Me ...

  3. RabbitMQ 可靠投递

    RabbitMQ 可靠投递 标签: RabbitMQ shovel-plugin ConfirmCallback RabbitMQ消息投递 背景 confirmCallback 确认模式 return ...

  4. iOS/MAC 数据压缩与解压缩及常用算法 LZMA、ZLIB

    苹果提供的常用的数据压缩算法LZMA.ZLIB.LZ4等: 这三种算法也是苹果建议的,可跨平台使用: 定义如下: /* Commonly-available encoders */ COMPRESSI ...

  5. 每天一个linux命令:df

    1.命令简介 df (disk free) 其功能显示每个文件所在的文件系统的信息,默认是显示所有文件系统. 2.用法 df [选项]... [文件]... 3.选项   4.示例 示例1:显示磁盘使 ...

  6. OpenLayers Node环境安装运行构建-支持Vue集成OpenLayers

    NodeJS 环境安装包下载:https://nodejs.org/zh-cn/download/ 安装vue-cli3.0.1: https://cli.vuejs.org/guide/instal ...

  7. 微表面分布函数(Microfacet Distribution Function)确切含义

    <Physically-Based Shading Models in Film and Game Production>中说:“D()的值不局限于0到1,可以任意大”,这句话使我比较好奇 ...

  8. 稀疏贴图 SparseTexture

    官方文档:https://docs.unity3d.com/Manual/SparseTextures.html 是一种虚拟贴图,可以动态的加载或卸载某一块tile.从而实现超大尺寸贴图的加载. 更新 ...

  9. Delphi Format 格式化数字

    Format('x=%d', [12]); //'x=12' //最普通Format('x=%3d', [12]); //'x= 12' //指定宽度Format('x=%f', [12.0]); / ...

  10. django项目添加utf-8编码支持中文

    代码中出现中文会报错: Non-ASCII character '...' in file ......models.py on line ......., but no encoding decla ...