QOJ.ac

QOJ

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

#20790. 블록

Statistics

어휘력을 늘리기 위해 소 Bessie는 나무 블록 네 개로 이루어진 세트를 얻었다. 각 블록은 정육면체이며, 여섯 면 각각에 알파벳 글자가 하나씩 적혀 있다. Bessie는 블록들을 한 줄로 배열하여 윗면의 글자들이 단어를 이루게 하면서 철자를 배우고 있다.

Bessie의 네 블록 각각에 적힌 글자와 만들고 싶은 단어 목록이 주어질 때, 목록에 있는 단어 중 블록으로 만들 수 있는 단어를 판별하여라.

입력

입력의 첫 번째 줄에는 Bessie가 만들고 싶은 단어의 수 $N$ ($1\le N\le 10$)이 주어진다. 다음 네 줄에는 각각 대문자 여섯 개로 이루어진 문자열이 주어지며, 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를 만들 수 있다. 안타깝게도 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.