#K47032. Word Search
Word Search
Word Search
You are given a rectangular grid of uppercase English letters with dimensions \(m \times n\) and a word. Your task is to determine whether the word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. Note that the same letter cell may not be used more than once.
Input Constraints:
- \(1 \leq m, n \leq 100\)
- The grid contains only uppercase letters.
- The word length is at least 1.
Example:
Input: 3 4 ABCE SFCS ADEE ABCCED</p>Output: Yes
inputFormat
The first line of the input contains two integers, \(m\) and \(n\), representing the number of rows and columns of the grid respectively. The next \(m\) lines each contain a string of length \(n\) denoting the grid rows. The final line contains the word to search for.
All input is provided via standard input (stdin).
outputFormat
Output a single line: Yes
if the word exists in the grid, otherwise No
.
Output should be written to standard output (stdout).
## sample3 4
ABCE
SFCS
ADEE
ABCCED
Yes
</p>