QOJ.ac

QOJ

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

#20790. 積み木

Statistics

語彙を増やすために、牛の Bessie は 4 個の木製の積み木を手に入れました。それぞれは立方体で、6 つの面のそれぞれにアルファベットの文字が書かれています。積み木を一列に並べて上面の文字で単語を作ることで、つづりを学んでいます。

Bessie の 4 個の積み木それぞれに書かれた文字と、彼女がつづりたい単語のリストが与えられます。リスト中のどの単語を積み木で作れるか判定してください。

入力

入力の最初の行には、Bessie がつづりたい単語の数 $N$ ($1\le N\le 10$) が与えられます。続く 4 行にはそれぞれ大文字 6 文字からなる文字列が与えられ、Bessie の積み木 1 個の 6 面の文字を表します。続く $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 を作れます。残念ながら、M のある唯一の積み木を同時に O にも使うことはできないため、MOO は作れません。R のある積み木がないため、FARM は作れません。C、D、E がすべて同じ積み木にあるため、CODE は作れません。

問題作成: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.