赵乐ACM

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2012年3月12日

摘要: 1.思路果然清晰了,十分钟搞定#include #include #include #include using namespace std; int n, k; queue q; int step[100010]; int bfs(int a) { if(a == k) return step[k]; else { if(a - 1 >= 0 && step[a - 1] == 0) { step[a - 1] = step[a] + 1; q.push(a... 阅读全文
posted @ 2012-03-12 20:22 赵乐ACM 阅读(205) 评论(0) 推荐(0)

摘要: 1.典型的bfs。2.难点在剪枝部分。有一个记录所走step的数组,记录到每个点所走的步数,如果一个点没走过,放进队列中,如果一个点走过,比较原来这个点的step值和由当前点计算的值,如果大,另其等于当前点的step值+1;3.这道题犯了超级低级的错误。。。写好了bfs()函数,结果在main()函数中没有添加bfs();语句,导致调试了好久得不到想要的结果。。。#include #include #include #include using namespace std; struct Node { int x, y; } sta, end; char a, c; in... 阅读全文
posted @ 2012-03-12 20:20 赵乐ACM 阅读(179) 评论(0) 推荐(0)