#P1101. 单词方阵
单词方阵
Description
Given an letter grid, there may be multiple occurrences of the word yizhong. Each word is placed contiguously along a single direction. Placement can be along any of the directions, and the direction does not change within the same word. Different words may cross and share letters. In the output, replace letters that are not part of any occurrence of the word with * to highlight the words.
Input Format
- The first line contains an integer ().
- Starting from the second line, input the letter matrix.
Output Format
Output the matrix where letters not belonging to any yizhong are replaced by *.
7
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
*******
*******
*******
*******
*******
*******
*******
8
qyizhong
gydthkjy
nwidghji
orbzsfgz
hhgrhwth
zzzzzozo
iwdfrgng
yyyygggg
*yizhong
gy******
n*i*****
o**z****
h***h***
z****o**
i*****n*
y******g
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号