那真的是退化了
一个简单的bfs都调了这么久。。。
题意是有h*w的矩阵
里面有空格也有X
然后指定两个坐标(这两个坐标都一定有X)
问你相连这两个点最短的segments,就是连起来的线段数,(并不是步数
,你看看图就明白,一开始我也不是很理解样例)
真的毒瘤题
一开始就想用bfs走一遍然后记录,就想着应该bfs走的最短路径应该就是最短segment,没想到wa了
然后看了discuss
的确毒瘤
上图是我画的我的代码后附的最后一组样例
这个也是测试数据里的一组真实数据
其实这个数据不全面,很多错误的只跑了一次目的地的程序都能跑对,只要你的方向顺序正确
http://poj.org/showmessage?message_id=176366
这是讨论里启发我的
然后我就知道不能只跑一遍目的地,要跑完全部的路取最小值
#include
#include
#include
#include
#include
#include
作者:离开那天
poj
小游戏