摘要: http://poj.org/problem?id=2531就是和原来的奶牛翻碗问题,翻黑白棋问题,开门问题属于一类题目,对于每一点只有两种状态,要么属于A要么属于DFS枚举出所有的状态即可。。才开始自己按自己的习惯写的DFS1469ms最后看了看别人的优化到了375ms。。。就是在处理求和时的优化了。。我的代码:View Code #include <iostream>#include <cstring>#include <cstdio>#define maxn 23using namespace std;bool vt[maxn];int n,ans;i 阅读全文
posted @ 2012-04-19 20:29 E_star 阅读(174) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3087刚看到题目的时候给我整蒙了,BFS怎么做啊?这不就是模拟一下洗牌的过程,如果遇到目标字符串就输出步数,如果回到原始串,就说明到不了目标串。View Code #include <iostream>#include <cstdio>#include <cstring>#include <queue>using namespace std;char aim[207];//目标串int n;struct node{ char s1[107]; char s2[107]; int len;};b 阅读全文
posted @ 2012-04-19 15:41 E_star 阅读(157) 评论(0) 推荐(0) 编辑