重构一遍就A了...但这样效率太低了...莫非都要重构???QWQ 每一秒男同志bfs3层,女同志bfs1层.注意扩展状态时,要判一下合不合法再扩展,而不是只判扩展的状态合不合法,否则有可能由非法的走到合法的地方. #include<cstdio> #include<iostream> #include<queue> #include<cstring> #define R register int ,,,},dy[]={,,,-}; using namesp…
HDU 3085 Nightmare Ⅱ(噩梦 Ⅱ) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description - 题目描述 Last night, little erriyue had a horrible nightmare. He dreamed that he and his girl friend were trapped in a…
Nightmare Ⅱ Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 886 Accepted Submission(s): 185 Problem Description Last night, little erriyue had a horrible nightmare. He dreamed that he and hi…
Problem Description Last night, little erriyue had a horrible nightmare. He dreamed that he and his girl friend were trapped in a big maze separately. More terribly, there are two ghosts in the maze. They will kill the people. Now little erriyue want…
思路: 最大步骤有20,直接BFS会超时. 因为知道开始情况和结果所以可以用双向BFS,每个BFS规定最大步骤为10,这样相加肯定小于20.这里要保存每个状态搜索到的最小步骤,用Hash储存.当发现现有状态已经在另一路出现了,那么就输出两者相加的步骤和. 代码: #include<iostream> #include<algorithm> #include<queue> #include<map> #define ll long long using nam…