report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Word search - FlandreOJ: Flandre Online Judge

Word search

Time limit: 1000 ms
Memory limit: 256 MB
Given a table with $n$ rows and $m$ columns consisting of uppercase letters, determine whether the word $S$ appears in the table. A word is considered to appear in the table if it can be formed by connecting adjacent cells in the table. Each cell can only be used once. Two cells are considered adjacent if they share an edge. For example, the words `REIMU` and `MARISA` exist in the following table:
### Input - The first line contains two integers $n$ and $m$. - The next $n$ lines each contain a string of length $m$ consisting of uppercase letters, representing the character table. - The last line contains the word $S$ consisting of uppercase letters. ### Output - Print `YES` if the word $S$ exists in the table; otherwise, print `NO`. ### Constraints - $1 \le n,m \le 6$. - $1 \le |S| \le 15$. ### Example Input: ``` 4 4 EIMU RTMA LFTR GASI MARISA ``` Output: ``` YES ```
Backtracking
Binary string
ABC string
Subset sum
Subset
Permutations
Group division
Knight's tour
N-queens problem
Maximum path
Knapsack
Build array
Sudoku
Minesweeper
Travelling Salesman Problem
Word search
Topic
Complete Search
Rating 800
Solution (0) Solution