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 ...
随机推荐
- bat获取文件夹里面所有文件夹的名称方法
创建一个123.txt文档,修改名称为123.bat 里面填写内容如下: DIR *.* /B >文件名清单.TXT 保存,双击执行即可获取生成文件夹名称的txt文档
- 禅道docker
64位电脑安装禅道,满足发送邮件功能 第一步: docker ps 查看docker中的容器是否有禅道(docker ps -a 这个指令看的是所有容器,包括未运行的)ps:登录服务器这个步骤没 ...
- Nginx 反向代理504 Gateway Time-out
location /ssfwpt { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_ ...
- SpringBoot2.x使用EasyPOI导入Excel浅谈
SpringBoot2.x使用EasyPOI导入Excel浅谈 平时经常遇到客户要帮忙导入一些数据到数据库中,有些数据比较多有时候手动录入就会很耗时间,所以就自己写一个Excel导入的demo记录一下 ...
- 使用Guava的RateLimiter完成简单的大流量限流
限流的一般思路: 1.随机丢弃一定规则的用户(迅速过滤掉90%的用户): 2.MQ削峰(比如设一个MQ可以容纳的最大消息量,达到这个量后MQ给予reject): 3.业务逻辑层使用RateLimite ...
- Linux下修改Mysql的用户(root)的密码的俩种方法
from:https://www.cnblogs.com/daizhuacai/archive/2013/01/17/2865138.html 修改的用户都以root为列.一.拥有原来的myql ...
- 系统管理员需知的 16 个 iptables 使用技巧
现代 Linux 内核带有一个叫 Netfilter[1] 的数据包过滤框架.Netfilter 提供了允许.丢弃以及修改等操作来控制进出系统的流量数据包.基于 Netfilter 框架的用户层命令行 ...
- DMA(直接存储器存取)
DMA(Direct Memory Access) DMA(Direct Memory Access)即直接存储器存取,是一种快速传送数据的机制. 工作原理 DMA是指外部设备不通过CPU而直接与系统 ...
- 重读redis设计与实现
重读了一遍redis设计与实现,这次收获也不错,把之前还有些疑惑的点:redis跳跃表的原理.redis持久化的方法.redis复制.redis sentinel.redis集群等,都重新熟悉了一遍, ...
- Git入门到高级系列2-git高级操作
视频课程地址 腾讯课堂 git 清理 git clean命令用来从你的工作目录中删除所有没有tracked过的文件. 命令 说明 git clean -n 告诉你哪些文件会被删除. 记住他不会真正的删 ...