- محدودیت زمان: ۱ ثانیه
- محدودیت حافظه: ۲۵۶ مگابایت
Once upon a time Mohammadreza and Mehrdad (M&M) decided to go to jungle to bring as many coconuts as possible. But unfortunately “Mehrzad the Kaftar” (his friends call him “Lion”) was following them. M&M are smart so they realised Lion was following them. When they just realised it, Mohammadreza climbed a tree and said to Mehrdad “Ble Ble Ble”!!!. Mehrdad couldn’t understand what Mohammadreza was saying and he was unable to climb trees so he ran. Mehrdad is good with geography so he knows jungle very well. He knows that there are some fences that only Lion can pass through (Lion jumps over it and takes 2 seconds) and some other fences that no one can pass (not Lion nor Mehrdad). There are also some Tunnels that Lion can not reach, so if Mehrdad gets there, he’s safe. Mehrdad is frightened so he can’t think, the only thing he can do is run. Mehrdad and lion move one cell at a time (1 second) and they can only move in four directions: up, down, left, right. Can you help him?
ورودی
First line of the input contains an integer $T (T ≤ 20)$ indicating number of test cases to follow. The first line of each test case will be given two integers $N$ and $M (1 ≤ N,M ≤ 500)$, the height and width of the jungle. Each of the following $N$ lines contain $M$ characters, describing the jungle. if $J$’th character of $i$’th line is ‘.’ it’s free cell, if it’s ‘M’ Mehrdad is there, if it’s ‘L’ Lion is there, if it’s ’O’ there is a tunnel there, if it’s ‘#’ there’s a long fence there and if it’s ‘+’ there’s a small fence there. If Mehrdad and Lion reach at same cell in a same time, Mehrdad will be eaten by Lion.
It’s guaranteed there are no more than 10 tunnels, and Mehrdad can always reach at least one tunnel (but he may be eaten in the way).
خروجی
For each test case output a line containing “Case $X$: ” (quotations for clarify) which $X$ is number of the test case. If Mehrdad can’t survive print “$good$ $bye$ $my$ $dear$ $good$ $friend$ $:($” (quotations for clarify). If Mehrdad can survive print the position of top left most (first $Top$, Then $Left$) tunnel he can reach.
مثالها
ورودی نمونه ۱
2
1 12
O.+.M..L..O.
1 12
O...M..L..O.
خروجی نمونه ۱
Case 1: good bye my dear good friend :(
Case 2: 1 1
ارسال پاسخ برای این سؤال