QOJ.ac

QOJ

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

#22380. Coggle

Statistics

휴가를 보내는 다른 이들처럼 소들도 단어 게임 Boggle의 소 버전인 Coggle을 한다. 비슷한 게임으로, 25개의 글자 주사위를 굴려 다음과 같은 행렬을 만든다.

           Z C C D X
           K Q M N B
           U O W Z Y
           F C O I J
           P A Q Z T

어떤 글자에서 시작하여 최대 여덟 이웃 중 하나로 계속 이동하면서 글자들이 사전의 단어를 만들면 단어를 완성하고 점수를 얻는다.

위 행렬에서 아래쪽 "$C$"는 "CAP", "COW", "COOK"를 만들 수 있지만 "COD"나 "PACK"은 만들 수 없다. 이 정사각형의 모든 사전 단어는 "CAP", "COOK", "COW", "OWN", "WIT", "WOO", "ZOO", "ZOOM"이다.

프로그램은 dict.txt에서 사전을 읽어야 한다. 사전은 알파벳순이며 단어가 25,000개 미만이고 각 단어는 20글자 이하이다. 실제 사전은 첨부 dict.txt로 제공되며 채점 중 작업 디렉터리에서 사용할 수 있다.

Bessie의 성적을 알아보자. 주사위를 나타내는 다섯 줄의 다섯 글자를 읽고 만들 수 있는 사전 단어 수를 구하라. 같은 단어에서 같은 주사위의 글자를 두 번 사용하지 마라.

만들 수 있는 단어 수를 세라. 한 단어를 여러 방법으로 만들 수 있으므로 단어를 만드는 방법의 수보다 작을 수 있다.

입력

  • $1,\ldots,5$번째 줄: $i$번째 줄에는 공백으로 구분된 대문자 다섯 개가 있고 행렬의 $i$번째 행을 나타낸다.

출력

  • $1$번째 줄: 설명한 규칙으로 만들 수 있는 사전 단어 수를 나타내는 정수 하나.

예제

입력 1

Z C C D X
K Q M N B
U O W Z Y
F C O I J
P A Q Z T

출력 1

8

문제 출처: Traditional, 2009

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.