{"trustable":true,"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":"\n\u003cdiv class\u003d\"panel_content\"\u003e\nAngel被MOLIGPY抓住了!他被Moligpy关进了监狱。监狱被描述为一个N * M(N,M \u003c\u003d 200)的矩阵。监狱中有墙壁、道路和守卫。\n\u003cbr\u003e\n\u003cbr\u003e\nAngel的朋友们想要救出Angel。他们的任务是:接近Angel。我们假设\"接近Angel\"就是到达Angel所在的位置。当一个守卫在格子里时,我们必须杀死他(或她)才能进入该格子。我们假设向上、向下、向右、向左移动都需要1个单位时间,杀死一个守卫也需要1个单位时间。而且我们足够强大,可以杀死所有的守卫。\n\u003cbr\u003e\n\u003cbr\u003e\n你需要计算接近Angel所需的最短时间。(我们只能向上、向下、向左和向右移动,当然要在边界内移动。)\n\u003cbr\u003e\n\u003c/div\u003e\n"}},{"title":"输入","value":{"format":"HTML","content":"第一行包含两个整数,表示N和M。\n\u003cbr\u003e\n\u003cbr\u003e\n接下来的N行,每行有M个字符。\".\"表示道路,\"a\"表示Angel,\"r\"表示Angel的每个朋友。\n\u003cbr\u003e\n\u003cbr\u003e\n一直处理到文件结束。\n\u003cbr\u003e"}},{"title":"输出","value":{"format":"HTML","content":"对于每个测试用例,你的程序应该输出一个整数,表示所需的最短时间。如果这样的数字不存在,你应该输出一行包含\"可怜的ANGEL必须在监狱里度过他的一生。\"\n\u003cbr\u003e"}},{"title":"示例","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003e输入\u003c/th\u003e\n \u003cth\u003e输出\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e7 8\r\n#.#####.\r\n#.a#..r.\r\n#..#x...\r\n..#..#.#\r\n#...##..\r\n.#......\r\n........\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e13\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}