QOJ.ac

QOJ

시간 제한: 1 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓

#17931. 巧克力保管箱

통계

Coco 有一个 $3 \times 3$ 方格网格形状的巧克力收纳盒。这个收纳盒的中心格子是被封死的,上面有一个显示数字的屏幕。其余的 8 个格子中,每个格子最多可以存放一块巧克力。

屏幕上最多会显示 4 个数字,每个数字表示含有巧克力的连通区域中格子的数量。如果有多个数字,它们会按升序显示。如果两个格子共享一条边,则称这两个格子是连通的。

Coco 想要再制作一个一模一样的巧克力收纳盒送给 Hanbyul。为了帮助担心可能存在 Bug 的 Coco,让我们来协助测试这个收纳盒。

输入格式

第一行给出测试用例的数量 $T$。($1 \le T \le 100$)

每个测试用例由 4 行组成。前 3 行给出巧克力收纳盒的状态。O 表示该格子中有巧克力,X 表示没有,中心格子用 - 表示。第 4 行按顺序给出屏幕上显示的数字个数 $n$ 以及数字列表 $a_1, a_2, \cdots, a_n$。($0 \le n \le 4$, $1 \le a_1 \le a_2 \le \cdots \le a_n \le 8$)

输出格式

对于每个测试用例,如果屏幕上的显示是正确的,则输出 1;否则输出 0

样例

输入样例 1

6
OOO
O-O
XOO
1 7
XOO
O-O
XXO
2 1 4
OXO
O-X
XXO
3 1 1 2
XOX
O-O
XOX
4 1 1 1 1
XOO
O-O
OOX
1 6
OXX
O-O
XXO
3 1 1 2

输出样例 1

1
1
1
1
0
0

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.