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 ...
随机推荐
- 【springboot】【redis】springboot+redis实现发布订阅功能,实现redis的消息队列的功能
springboot+redis实现发布订阅功能,实现redis的消息队列的功能 参考:https://www.cnblogs.com/cx987514451/p/9529611.html 思考一个问 ...
- Nginx之——日志按日期分割的实现(基于CentOS操作系统)
Nginx自身是没有按日期切割日志的功能,可以用shell脚本实现.新建一个cut_log.sh, #!/bin/sh # Program: # Auto cut nginx log script. ...
- IntelliJ IDEA使用maven-javadoc-plugin生成Java Doc控制台乱码
问题描述 在使用IDEA生成Java Doc的过程中,发现IDEA控制台乱码,作为有轻微代码强迫症的我来说,这是不可忍受的,需要鼓捣一番.先上pom.xml中的javadoc插件配置 <!--配 ...
- one-stage object detectors(1)
2019/04/08 强烈推荐:深入理解one-stage目标检测算法 yolo系列 one-stage object detectors(YOLO and SSD) 在不专一的模型中,每个检测器应该 ...
- Django表单介绍
HTML 表单 在HTML中,表单是<form>...</form> 之间元素的集合,它们允许访问者输入文本.选择选项.操作对象和控制等等,然后将信息发送回服务器. 某些表单的 ...
- 安装最新版RabbitMQ v3.7.13 以及基本配置
之前用的老版本,新项目新气象,RabbitMQ也用最新版吧 首先打开官网:http://www.rabbitmq.com/install-rpm.html 先到右侧导航栏来看一下 : 第一个红框是指的 ...
- SATA主机协议的FPGA实现之准备工作
SATA主机协议的FPGA实现之准备工作 从2月中旬准备开始,经过3个月的奋战,我的又一个项目--基于FPGA的固态硬盘读写控制电路,已经基本实现.由于实用资料的匮乏,以及项目本身颇具挑战性,这个 ...
- 如何在宿主机上查看kvm虚拟机的IP
# arp -a ? (:3c:ce::f2: [ether] on br0 gateway (:c8:ac:d5 [ether] on br0 ? (:d4:fc: [ether] on br0 ? ...
- 【iCore4 双核心板_uC/OS-II】例程六:信号量——任务同步
一.实验说明: 信号量是一个多任务内核提出的一个协议机构,上一个实验中我们介绍了信号量访问共享资源 的功能,其实信号量最初是用来控制访问共享资源的,它还可以用来同步一个中断服务函数和一个任 务,或者同 ...
- 通过inotify实现反调试
1.inotify linux下inotify可以实现监控文件系统事件(打开,读写删除等),inotify最常见的api有以下几个: inotify_init:用于创建一个 inotify 实例的系统 ...