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.