QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100

#4637. برج الخلايا

Statistics

Cell Tower لعبة ألغاز يومية ممتعة: https://www.andrewt.net/puzzles/cell-tower/.

ننظر هنا في نسخة مبسطة. يُعطى لك مربع بحجم $8\times8$ في كل خلية منه محرف واحد، وقاموس. قسّم المربع إلى عدة أجزاء بحيث يكون كل جزء كتلة متصلة، وتشكّل المحارف في تلك الكتلة (من الأعلى إلى الأسفل ومن اليسار إلى اليمين) كلمة صالحة (أي موجودة في القاموس).

تُسمّى الخليتان $A,B$ زوجًا متصلًا إذا اشتركتا مباشرة في ضلع واحد، أو وُجدت خلية أخرى $C$ بحيث يكون كل من $A,C$ و $B,C$ زوجًا متصلًا.

تُسمّى مجموعة خلايا كتلة متصلة إذا كان كل زوج من خلاياها زوجًا متصلًا وكان حجم المجموعة إما $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.