QOJ.ac

QOJ

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

#20790. 積木

Statistics

為了擴大詞彙量,乳牛 Bessie 得到了一套四塊木製積木,每塊都是一個立方體,六個面上各寫著一個字母。她正在學習拼字:將積木排成一行,使積木頂面的字母拼成單字。

給定 Bessie 的四塊積木各面上的字母,以及她想拼寫的單字列表,請確定列表中的哪些單字能用這些積木成功拼出。

輸入格式

輸入的第一行包含 $N$ ($1\le N\le 10$),表示 Bessie 想拼寫的單字數。接下來四行,每行包含一個由六個大寫字母組成的字串,表示 Bessie 的一塊積木六個面上的字母。接下來 $N$ 行包含 Bessie 想拼寫的 $N$ 個單字。每個單字由 1 到 4 個大寫字母組成。

輸出格式

對於 Bessie 列表中的每個單字,如果她能用這些積木拼出它,輸出 YES,否則輸出 NO。

範例

輸入格式 1

6
MOOOOO
OOOOOO
ABCDEF
UVWXYZ
COW
MOO
ZOO
MOVE
CODE
FARM

輸出格式 1

YES
NO
YES
YES
NO
NO

說明

在這個範例中,Bessie 可以拼出 COW、ZOO 和 MOVE。可惜,她無法拼出 MOO,因為唯一帶有 M 的積木不能同時用來提供 O。她無法拼出 FARM,因為沒有帶有字母 R 的積木。她無法拼出 CODE,因為 C、D 和 E 都在同一塊積木上。

題目作者:Brian Dean

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.