#P7262. Microphone Water Damage Simulation
Microphone Water Damage Simulation
Microphone Water Damage Simulation
Porter's microphone contains critical electronic components arranged on a $n \times m$ grid. Each cell in the grid is represented by a character:
.
: an empty spacex
: a critical electronic componento
: a water drop
A water drop flows continuously in the direction of gravity until it either exits the grid or hits an electronic component. When a water drop reaches any cell containing a component (i.e. x
), the microphone is considered broken.
You are given the grid and the current gravity direction, which is one of ^
, v
, <
, or >
corresponding to up, down, left, and right respectively. Determine whether, after some time, the microphone will be damaged.
inputFormat
The input consists of several lines. The first line contains two integers n and m and a character g representing the number of rows, number of columns, and the gravity direction respectively.
The following n lines each contain m characters, representing the grid.
It is guaranteed that g
is one of ^
, v
, <
, or >
.
outputFormat
Output Yes
if any water drop eventually reaches an electronic component. Otherwise, output No
.
sample
3 3 v
...
.o.
..x
No