시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 4 | 2 | 2 | 50.000% |
You just bought a new robotic vacuum cleaner, and you love to watch it explore your room. Through careful observation, you have determined that it follows the following navigation rules:
Unfortunately, you just spilled your drink on the carpet. Given the current position of the robot and the position of your spill, determine how many steps it will take your robot to clean your mess. The robot cleans a mess as soon as it enters a space, so cleaning takes no additional power.
The first line will be a single integer representing the number of test-cases. Each test case will start with two numbers separated by a space, n and d. n represents the size of your room, which is an n-by-n unit square. d is the total distance that your robot can travel on a single charge. n will be between 5 and 20, d will be between 15 and 30.
The following n lines will each contain n characters with the following meanings:
There will be at most 500 test cases.
For each case, output the line “Case x:” where x is the case number, on a single line followed by a single space and the number of minutes that it will take your robot to reach your mess. If the robot will never reach your mess, output the word ’NEVER’.
2 5 10 xxpxx x---x x-m-x xr--x xxxxx 10 30 xxxxxxxxxx x-x------x x--------x xr-xx----x x--xx----p xm-------x xx------xx xxxx-----x x--------x xxxxxxxxxx
Case 1: NEVER Case 2: 51