QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 1024 MB 満点: 100

#4637. 基站

統計

Cell Tower 是一个有趣的日常益智游戏,网址为 https://www.andrewt.net/puzzles/cell-tower/。

在此我们考虑一个简化版本。给定一个 $8 \times 8$ 的方格,每个单元格中有一个字符,以及一个字典。请将该方格划分为若干部分,使得每一部分都是一个连通块,且该连通块中的字符(从上到下,从左到右)构成一个有效的单词(即出现在字典中)。

如果两个单元格 $A$ 和 $B$ 直接共享同一条边,或者存在另一个单元格 $C$ 使得 $A, C$ 和 $B, C$ 均为连通对,则称 $A$ 和 $B$ 为连通对。

如果一组单元格中任意两个单元格均为连通对,且该组的大小为 3 或 4,则称该组单元格为一个连通块。

输入格式

输入的前 8 行,每行包含 8 个整数 $Sq_{i,j} (0 \le Sq_{i,j} \le 9)$,表示给定的 $8 \times 8$ 方格。 下一行包含一个整数 $n (1 \le n \le 11000)$,表示字典的大小。 接下来的 $n$ 行,每行包含一个字符串 $S_i (3 \le |S_i| \le 4)$,描述字典中的单词。 $S_i$ 的字符集为 $\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\}$。

输出格式

请输出有效划分的数量。

样例

输入 1

1 1 1 1 2 3 3 3
0 4 4 4 2 2 2 3
0 0 5 5 6 6 7 7
0 9 5 5 6 8 7 7
9 9 9 1 6 8 8 8
3 1 1 1 2 2 2 2
4 5 6 0 0 4 4 3
7 8 9 0 0 4 3 3
16
1111
2222
3333
444
0000
5555
6666
7777
8888
9999
111
333
3456
789
3478
569

输出 1

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.