http://poj.org/problem?id=3414

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <queue>
  4. #include <cstring>
  5.  
  6. using namespace std;
  7.  
  8. struct node{
  9. int first;
  10. int second;
  11. int opera[];
  12. int cou;
  13. };
  14. queue<node> que;
  15. int vis[][];
  16.  
  17. //opera数组数据意义
  18. //fill(1) 110----120
  19. //drop(1) 210----220
  20. //pour(1,2) 312----321
  21. //三位数分别表示操作,第一个参数,第二个参数
  22.  
  23. node bfs(int a,int b,int c){
  24. node ff;
  25. ff.first=;
  26. ff.second=;
  27. ff.cou=;
  28. que.push(ff);
  29. node t;
  30. memset(vis,,sizeof(vis));
  31. while(!que.empty()){
  32. node f=que.front();
  33. que.pop();
  34. if(f.first==c||f.second==c){
  35. return f;
  36. }
  37. t=f;
  38. t.first=a;
  39. t.opera[t.cou++]=;
  40. if(vis[t.first][t.second]!=){
  41. que.push(t);
  42. }
  43. vis[t.first][t.second]=;
  44.  
  45. t=f;
  46. t.first=;
  47. t.opera[t.cou++]=;
  48. if(vis[t.first][t.second]!=){
  49. que.push(t);
  50. }
  51. vis[t.first][t.second]=;
  52.  
  53. t=f;
  54. int l=b-t.second;
  55. if(t.first>=l){
  56. t.second=b;
  57. t.first-=l;
  58. }else{
  59. t.second+=t.first;
  60. t.first=;
  61. }
  62. t.opera[t.cou++]=;
  63. if(vis[t.first][t.second]!=){
  64. que.push(t);
  65. }
  66. vis[t.first][t.second]=;
  67.  
  68. t=f;
  69. t.second=b;
  70. t.opera[t.cou++]=;
  71. if(vis[t.first][t.second]!=){
  72. que.push(t);
  73. }
  74. vis[t.first][t.second]=;
  75.  
  76. t=f;
  77. t.second=;
  78. t.opera[t.cou++]=;
  79. if(vis[t.first][t.second]!=){
  80. que.push(t);
  81. }
  82. vis[t.first][t.second]=;
  83.  
  84. t=f;
  85. l=a-t.first;
  86. if(t.second>=l){
  87. t.first=a;
  88. t.second-=l;
  89. }else{
  90. t.first+=t.second;
  91. t.second=;
  92. }
  93. que.push(t);
  94. vis[t.first][t.second]=;
  95. }
  96. }
  97.  
  98. int main()
  99. {
  100. int a,b,c;
  101. while(~scanf("%d %d %d",&a,&b,&c)){
  102. if(a==b&&b==c){
  103. printf("1\n");
  104. printf("FILL(1)\n");
  105. continue;
  106. }else if(a==b&&b!=c||c>a&&c>b){
  107. printf("impossible\n");
  108. continue;
  109. }
  110. node ans=bfs(a,b,c);
  111. printf("%d\n",ans.cou);
  112. for(int i=;i<ans.cou;i++){
  113. int baiwei=ans.opera[i]%;
  114. int shiwei=ans.opera[i]/%;
  115. int gewei=ans.opera[i]%;
  116. if(baiwei==){
  117. if(shiwei==){
  118. printf("FILL(%d)\n",);
  119. }else{
  120. printf("FILL(%d)\n",);
  121. }
  122. }else if(baiwei==){
  123. if(shiwei==){
  124. printf("DROP(%d)\n",);
  125. }else{
  126. printf("DROP(%d)\n",);
  127. }
  128. }else if(gewei==){
  129. printf("POUR(%d,%d)\n",shiwei,gewei);
  130. }
  131. }
  132. }
  133. return ;
  134. }

这个代码有毒,没法调试啊

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. python测试开发django-56.模板渲染markdown语法+代码高亮

    前言 上一篇已经实现在xadmin后台编辑markdown语法的文档,编辑完成之后发布博客,在前端html能把markdown语法显示出来. 主要思路是先从数据库把markdown的代码读出来,导入m ...

  2. Spring Boot参数校验

    1. 概述 作为接口服务提供方,非常有必要在项目中加入参数校验,比如字段非空,字段长度限制,邮箱格式验证等等,数据校验常用到概念:JSR303/JSR-349: JSR303是一项标准,只提供规范不提 ...

  3. JAVA中通过Jedis操作Redis连接与插入简单库

    一.简述 JAVA中通过Jedis操作Redis连接与插入简单库 二.依赖 <!-- https://mvnrepository.com/artifact/redis.clients/jedis ...

  4. golang 使用pprof和go-torch做性能分析

    软件开发过程中,项目上线并不是终点.上线后,还要对程序的取样分析运行情况,并重构现有的功能,让程序执行更高效更稳写. golang的工具包内自带pprof功能,使找出程序中占内存和CPU较多的部分功能 ...

  5. Effective Java 第三版——83. 明智谨慎地使用延迟初始化

    Tips 书中的源代码地址:https://github.com/jbloch/effective-java-3e-source-code 注意,书中的有些代码里方法是基于Java 9 API中的,所 ...

  6. 云服务jdk 升级为 OpenJDK11

    由于oracle是个碧池,大家都懂,今年来,jdk版本更新的越来越频繁,所以目前商业版本需要收费了 每个企业都要考虑这样的问题,所以嘛,新项目试水肯定是要的,用openJDK11吧, https:// ...

  7. Unity StreamingMipmaps 简单测试

    StreamingMipmaps是Unity2018.2中加入的新功能,意指通过CPU控制,只加载部分Mipmap图片以节省更多的内存及显存空间. 我测试时遇到了问题,后来发现必须打包出来测才有效(注 ...

  8. AWS免费套餐服务器部署NETCORE网站

    之前的linode充了5美元,一个月就用完了,还是创建的最便宜的服务器的!!! 以前一直想用用aws的所谓的免费套餐服务器的,现在linode过期了,可以试着用用了 下面是我的操作流程,包含错误及解决 ...

  9. MongoDB Notes

    MongoDB 启动一个 mongo 实例 $ docker run --name some-mongo -d daocloud.io/mongo 由于该镜像的 Dockerfile 中包含了 EXP ...

  10. [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. ...