摘要: 刚拿到这题时很纠结,没有思路。后来想了一天,问了问高手终于把思路整理出来。思路:三个瓶子,无非就是6种倒法,按杯子体积从大到小定义为s, m, n。则6种倒法分别是:s -> m, s -> n, m -> n, m -> s, n -> m, n -> s;加一个标记变量,标记当前状态已经出现过。将没出现过的状态入队列,剩下的就是bfs的事了。。。My Code:#include <iostream>#include <cstdio>#include <cstring>using namespace std;const 阅读全文
posted @ 2011-09-02 21:49 AC_Von 阅读(254) 评论(0) 推荐(0) 编辑
摘要: 这题用bfs做的,总结出来一条真理!在用bfs时,如果要引用结构体定义中的值,一定加中间变量,不要直接在上边操作。思路:直接用bfs找终点,如果中途遇到map[i][j] == 4的点,就把time置为6, 把走过的map[i][j] == 4的点标记为0;My Code:#include <iostream>#include <cstdio>#include <cstring>using namespace std;struct nightmare{ int i; int j; int t; int step;}q[10000];int d[4][2] = 阅读全文
posted @ 2011-09-02 19:33 AC_Von 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 此题做的相当爽,为什么爽呢,因为。。。连带TLE, RE, WA。总共错了11次。。。有一个地方没考虑清楚,然后再怎么剪枝都WA,最后ZZ一句话惊醒梦中人,总于A了。思路:这题要求方向改变次数。用一个变量记录上一次的方向,与下一次向比较,如果不同则加1。My Code:#include <iostream>#include <cstdio>#include <cstring>#define ud 1; //标记上下方向#define lr 2; //标记左右方向using namespace std;int map[1005][1001]; //存放每次询问 阅读全文
posted @ 2011-09-02 15:56 AC_Von 阅读(294) 评论(0) 推荐(0) 编辑