QOJ.ac

QOJ

Süre Sınırı: 2 s Bellek Sınırı: 1024 MB Toplam puan: 100

#4637. 細胞塔

İstatistikler

Cell Tower 係一款有趣嘅每日解謎遊戲:https://www.andrewt.net/puzzles/cell-tower/。

呢度我哋考慮一個簡化版本。畀你一個 $8\times8$ 嘅正方形,每格有一個字元,另外仲有一本字典。請將個正方形分成幾個部分,令每部分都係一個連通塊,而連通塊入面嘅字元(由上到下、由左到右)組成一個有效單字(即係字典入面有嘅單字)。

如果格仔 $A$ 同 $B$ 直接共用同一條邊,或者存在另一個格仔 $C$,令 $A,C$ 同 $B,C$ 都係連通對,就叫呢兩個格仔 $A,B$ 做連通對。

如果一組格仔入面任何兩格都係連通對,而且呢組有 $3$ 或 $4$ 格,就叫呢組格仔做連通塊。

輸入格式

輸入頭 $8$ 行每行有 $8$ 個整數 $Sq_{i,j}$($0\le Sq_{i,j}\le9$),表示畀定嘅 $8\times8$ 正方形。

下一行有一個整數 $n$($1\le n\le11000$),表示字典嘅大小。

跟住 $n$ 行,每行有一個字串 $S_i$($3\le|S_i|\le4$),描述字典入面嘅單字。$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.