Searching for the telecos

(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.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T12:16:40.193Z

© Jutge.org, 2006–2026.
https://jutge.org
