luogu#P9303. [CCC 2023 J5] CCC Word Hunt
[CCC 2023 J5] CCC Word Hunt
题目描述
In the CCC Word Hunt, words are hidden in a grid of letters. The letters of a hidden word always appear in order on horizontal, vertical, or diagonal line segments in one of two ways.One way is for the letters of a word to appear on one line segment. The other way is for the letters of a word to appear on one line segment up to some letter and then on a second line segment that forms a right angle at this letter.
Given a grid of letters and a single word to search for, your job is to determine the number of times that particular word is hidden in the grid.
输入格式
The first line of input will contain a string of distinct uppercase letters ,representing the word you are to search for in the grid. The length of will be at least two. The second line of input will be an integer , where is the number of rows in the grid.The third line of input will be an integer , where is the number of columns in the grid.
The remaining input will provide the letters in the grid. It will consist of lines, where each line contains uppercase letters separated by single spaces.
输出格式
The following table shows how the available 15 marks are distributed:
Marks | Word Placement |
---|---|
On one horizontal line segment | |
On one horizontal or vertical line segment | |
On one horizontal, vertical, or diagonal line segment | |
On one line segment or two perpendicular line segments |
The output will consist of a single non-negative integer , representing the number of times the word is hidden in the grid.
题目大意
在 CCC Word Hunt 这款游戏中,它的每一关都会给你一个目标字符串 (),然后你需要在一个 ()的矩阵中寻找这个字符串,而且找到目标字符串的方法有且仅有 种,分别为:
-
这个隐藏字符串按水平、垂直或对角斜线排成了一条直线。
-
这个隐藏字符串先进行一段,然后转 度再进行一段。
请计算出该 的矩阵中一共包含几个隐藏字符串。
MENU
5
7
F T R U B L K
P M N A X C U
A E R C N E O
M N E U A R M
M U N E M N S
3
NATURE
6
9
N A T S F E G Q N
S A I B M R H F A
C F T J C U C L T
K B H U P T A N U
D P R R R J D I R
I E E K M E G B E
4
提示
本题采用捆绑测试。
- Subtask ( points):隐藏字符串一定在一条水平线段上。
- Subtask ( points):隐藏字符串一定在一个水平或垂直线段上。
- Subtask ( points):隐藏字符串一定在一个水平、垂直或对角线线段上。
- Subtask ( points):隐藏字符串一定在一个线段或两个互相垂直的线段上。
样例 图解:
样例 图解: