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 ...
随机推荐
- python测试开发django-56.模板渲染markdown语法+代码高亮
前言 上一篇已经实现在xadmin后台编辑markdown语法的文档,编辑完成之后发布博客,在前端html能把markdown语法显示出来. 主要思路是先从数据库把markdown的代码读出来,导入m ...
- Spring Boot参数校验
1. 概述 作为接口服务提供方,非常有必要在项目中加入参数校验,比如字段非空,字段长度限制,邮箱格式验证等等,数据校验常用到概念:JSR303/JSR-349: JSR303是一项标准,只提供规范不提 ...
- JAVA中通过Jedis操作Redis连接与插入简单库
一.简述 JAVA中通过Jedis操作Redis连接与插入简单库 二.依赖 <!-- https://mvnrepository.com/artifact/redis.clients/jedis ...
- golang 使用pprof和go-torch做性能分析
软件开发过程中,项目上线并不是终点.上线后,还要对程序的取样分析运行情况,并重构现有的功能,让程序执行更高效更稳写. golang的工具包内自带pprof功能,使找出程序中占内存和CPU较多的部分功能 ...
- Effective Java 第三版——83. 明智谨慎地使用延迟初始化
Tips 书中的源代码地址:https://github.com/jbloch/effective-java-3e-source-code 注意,书中的有些代码里方法是基于Java 9 API中的,所 ...
- 云服务jdk 升级为 OpenJDK11
由于oracle是个碧池,大家都懂,今年来,jdk版本更新的越来越频繁,所以目前商业版本需要收费了 每个企业都要考虑这样的问题,所以嘛,新项目试水肯定是要的,用openJDK11吧, https:// ...
- Unity StreamingMipmaps 简单测试
StreamingMipmaps是Unity2018.2中加入的新功能,意指通过CPU控制,只加载部分Mipmap图片以节省更多的内存及显存空间. 我测试时遇到了问题,后来发现必须打包出来测才有效(注 ...
- AWS免费套餐服务器部署NETCORE网站
之前的linode充了5美元,一个月就用完了,还是创建的最便宜的服务器的!!! 以前一直想用用aws的所谓的免费套餐服务器的,现在linode过期了,可以试着用用了 下面是我的操作流程,包含错误及解决 ...
- MongoDB Notes
MongoDB 启动一个 mongo 实例 $ docker run --name some-mongo -d daocloud.io/mongo 由于该镜像的 Dockerfile 中包含了 EXP ...
- [HDFS Manual] CH2 HDFS Users Guide
2 HDFS Users Guide 2 HDFS Users Guide 2.1目的 2.2.概述 2.3.先决条件 2.4. Web Interface 2.5. Shell Command 2. ...