POJ 3414 pots (未解决)
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 (未解决)的更多相关文章
- BFS POJ 3414 Pots
题目传送门 /* BFS:六种情况讨论一下,BFS轻松解决 起初我看有人用DFS,我写了一遍,TLE..还是用BFS,结果特判时出错,逗了好长时间 看别人的代码简直是受罪,还好自己终于发现自己代码的小 ...
- 广搜+输出路径 POJ 3414 Pots
POJ 3414 Pots Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13547 Accepted: 5718 ...
- POJ 3414 Pots(罐子)
POJ 3414 Pots(罐子) Time Limit: 1000MS Memory Limit: 65536K Description - 题目描述 You are given two po ...
- poj 3414 Pots 【BFS+记录路径 】
//yy:昨天看着这题突然有点懵,不知道怎么记录路径,然后交给房教了,,,然后默默去写另一个bfs,想清楚思路后花了半小时写了120+行的代码然后出现奇葩的CE,看完FAQ改了之后又WA了.然后第一次 ...
- poj 3414 Pots【bfs+回溯路径 正向输出】
题目地址:http://poj.org/problem?id=3414 Pots Time Limit: 1000MS Memory Limit: 65536K Total Submissions ...
- POJ 3414 Pots
Pots Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status ...
- POJ 3414 Pots【bfs模拟倒水问题】
链接: http://poj.org/problem?id=3414 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22009#probl ...
- poj 3414 Pots(广搜BFS+路径输出)
转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:id=3414">http://poj.org/probl ...
- poj 3414 Pots ( bfs )
题目:http://poj.org/problem?id=3414 题意:给出了两个瓶子的容量A,B, 以及一个目标水量C, 对A.B可以有如下操作: FILL(i) fill the ...
随机推荐
- 安装istio v1.0 详细过程和步骤
创建 istio 目录 [root@centos-110 ~]# mkdir istio [root@centos-110 ~]# cd istio 方案一: # 去下面的地址下载压缩包 # ...
- python测试开发django-56.模板渲染markdown语法+代码高亮
前言 上一篇已经实现在xadmin后台编辑markdown语法的文档,编辑完成之后发布博客,在前端html能把markdown语法显示出来. 主要思路是先从数据库把markdown的代码读出来,导入m ...
- WSDL测试webservice接口记录
收到一个事情,需要对接第三方API,对方给了个service,看了一下,原来是webservices的. 上一次测试webervice的接口,还是至少八九年前的时候了,这种相对比较老旧的也好久不在使用 ...
- Python之关于工具包简介
1.Pandas Python Data Analysis Library 或 pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的.Pandas 纳入了大量库和一些标准的 ...
- iOS性能优化篇 —— 耗电优化总结
手机App耗电的主要来源有以下四个因素: CPU处理,Processing 网络,Networking 定位,Location 图像,Graphics 耗电优化最终目的:通过尽可能降低CPU ...
- System.Net.HttpWebRequest.GetResponse() 远程服务器
WebException 服务器状态码错误,比如500服务器内部错误 现象 我们编码实现请求一个页面时,请求的代码类似如下代码: HttpWebRequest req = (HttpWebReques ...
- LaTeX数学模式&上下标&代码块
效果就是如上图所示了.学习了使用数学模式插入公式和使用上标和公式的编号.这里的目录没有展开,在编译一次目录会展开,代码块会被挤到下一页上面去. \documentclass[UTF8]{ctexart ...
- create-react-app入门教程
Create React App是FaceBook的React团队官方出的一个构建React单页面应用的脚手架工具.它本身集成了Webpack,并配置了一系列内置的loader和默认的npm的脚本,可 ...
- [转]JS判断字符串是否为json数据
原文地址:https://blog.csdn.net/qq_26400953/article/details/77411520 这周碰到了很多问题,尽量把遇到的问题都记录下来. JS判断字符串是否为j ...
- 具体解释MVP矩阵之ViewMatrix
矩阵推导 ViewMatrix用于直接将World坐标系下的坐标转换到Camera坐标系下.已知相机的坐标系.还有相机在世界空间下的坐标.就能够求出ViewMatrix.以下进行具体推导. 令UVN为 ...