Searching for the telecos P98259


Statement
 

pdf   zip

thehtml

(The original statement in Catalan has many private jokes. This English version goes straight to the point of the problem.)

Write a program to search for someone called “the telecos” on a given rectangular grid.

Input

Input has several cases. Each case begins with two numbers n and m between 1 and 100. Follow n lines with m characters each: a dot indicates a free cell, a ‘P’ indicates a person, a ‍‘#’ indicates a wall, and a ‘T’ indicates the telecos. The search must always begin from the upper-left cell (which never has a wall), and there is at most one telecos on the grid.

Output

For every case, if it is possible to reach the telecos, print the minimum number of steps to do so, and also the maximum number of persons that can be met in a path to the telecos with the minimum lenght. You can make horizontal and vertical movements, never leaving the grid. If the telecos is not in the grid, or if he is not reachable, tell so.

Public test cases
  • Input

    1 4
    ....
    2 2
    ..
    .T
    2 2
    .P
    .T
    2 2
    ..
    PT
    2 2
    .#
    #T
    4 6
    P#TPPP
    .#.PPP
    .#PPPP
    ...PPP
    1 1
    T
    

    Output

    The telecos ran away.
    2 0
    2 1
    2 1
    The telecos is hidden.
    8 2
    0 0
    
  • Information
    Author
    Alex Alvarez
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++