{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"lmh学长被hjq学长抓住了!hjq学长把lmh学长关进了禁闭室。禁闭室被描述为一个N*M(N,M\u003c\u003d200)矩阵。\u003cbr\u003e\n禁闭室里有墙,有路,有警卫。善良的同学们想救lmh学长。他的任务是:接近lmh学长。我们假设“接近lmh学长”就是到达lmh学长停留的位置。\u003cbr\u003e当有警卫在格子里时,善良的同学们必须杀了警卫才能进入格子里。我们假设上、下、右、左移动需要1个单位的时间,杀死一个警卫也需要1个单位的时间。我们有足够的力量杀死所有的警卫。 你必须计算接近lmh学长的最短的时间(当然,我们只能上下左右移动到边界内的相邻网格。)"}},{"title":"Input","value":{"format":"HTML","content":"第一行包含两个整数,分别代表N和m。 接着是N行,每行有M个字符。“.”代表路,“a”代表lmh学长,“r”代表lmh学长的每一个朋友,\"x\"表示警卫. 处理到文件末尾。\n\u003cbr\u003e注意是多组输入!"}},{"title":"Output","value":{"format":"HTML","content":"对于每个测试用例,您的程序应该输出一个整数,表示所需的最小时间。如果这样的数字不存在,你应该输出一行\"Poor ANGEL has to stay in the prison all his life.\""}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003e7 8\n#.#####.\n#.a#..r.\n#..#x...\n..#..#.#\n#...##..\n.#......\n........\n\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003e13\n\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}