[Home|Training|Problems|Contests|C Language] | [Login|Register] |

Problems Status Rank |
Problem 1287
Elite VIP
Time Limit: 1000ms
Memory Limit: 65536kb Description
Very Important Pig (VIP) is an interesting game played on an There are 4 types of cells in the grid: empty(“ Our VIP(“ -
If the VIP is on a ladder:
- He will move to the right cell if it’s empty or a ladder.
- Or move to the top cell if it’s empty or a ladder. He won’t do this if the right cell is empty or a ladder.
- Otherwise, the VIP will stay where he was.
- If the VIP is NOT on a ladder:
- He will fall into the below cell if it’s empty.
- Or move to the right cell if it’s empty or a ladder. He won’t do this if the below cell is empty.
- Otherwise, the VIP will stay where he was.
The goal of game is to help our VIP go back home(“ Input
The input consists of multiple test cases. Each case begins with two integers The input ends with Output
For each test case, output the minimum number of cells to be dug after “ Sample Input
1 3 P*H 3 5 *#@.H *#**# P#*** 4 6 P@*#.* *@#@.H *@#@.# *.#@.# 4 5 P.... ****@ #*#.. ****H 1 2 HP 2 3 @H* P#. 2 3 @H* P#* 0 0 Sample Output
Case 1: 1 Case 2: 2 Case 3: 4 Case 4: 1 Case 5: oops Case 6: oops Case 7: 0 Hint
Following figure shows VIP’s path(“ *#@.o *oooo oo*** |

University of Science and Technology of China

Online Judge for ACM/ICPC

Processed in 1.5ms with 1 query(s).

Online Judge for ACM/ICPC

Processed in 1.5ms with 1 query(s).