시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 87 16 5 16.129%

문제

5 x 5 행렬에 대문자 알파벳이 하나씩 들어간 퍼즐이 있다. 그리고 이 행렬에서 주어진 단어들을 찾는 것이다. 찾는 방법은 임의의 시작점에서 시작하여 인접한 8방향으로 뻗어나가면서 알파벳을 이어나가는 것이다. 찾을 단어들은 문제와 함께 배포된 dict.txt에 들어있는 단어들이다.

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

위와 같은 퍼즐이 있을 때 CAP, COW, COOK 등은 퍼즐에서 찾을 수 있지만 COD, PACK 등은 찾을 수 없다.

문제는 퍼즐이 주어졌을 때, 퍼즐 속에 총 몇 개의 단어가 있는지 구하는 것이다.

입력

다섯 줄에 걸쳐 5 x 5알파벳 퍼즐이 공백으로 구분되어 주어진다.

출력

첫 줄에 포함되는 총 단어 개수를 출력한다.

예제 입력 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

힌트

dict.txt는 여기에 압축되어 있다.

W3sicHJvYmxlbV9pZCI6IjExNjUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIyZThcdWM1YjRcdWQzN2NcdWM5OTAiLCJkZXNjcmlwdGlvbiI6IjxwPjUgeCA1IFx1ZDU4OVx1YjgyY1x1YzVkMCBcdWIzMDBcdWJiMzhcdWM3OTAgXHVjNTRjXHVkMzBjXHViY2IzXHVjNzc0IFx1ZDU1OFx1YjA5OFx1YzUyOSBcdWI0ZTRcdWM1YjRcdWFjMDQgXHVkMzdjXHVjOTkwXHVjNzc0IFx1Yzc4OFx1YjJlNC4gXHVhZGY4XHViOWFjXHVhY2UwIFx1Yzc3NCBcdWQ1ODlcdWI4MmNcdWM1ZDBcdWMxMWMgXHVjOGZjXHVjNWI0XHVjOWM0IFx1YjJlOFx1YzViNFx1YjRlNFx1Yzc0NCBcdWNjM2VcdWIyOTQgXHVhYzgzXHVjNzc0XHViMmU0LiB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dodCB3ZWxsIGJlIHNtYWxsZXIgdGhhbiB0aGUgbnVtYmVyIG9mIHdheXMgYSB3b3JkIGEgY2FuIGJlIGZvcm1lZCBzaW5jZSB3b3JkcyBtaWdodCBiZSBmb3JtZWQgaW4gbW9yZSB0aGFuIG9uZSB3YXkpLjxcL3A+XHJcbiIsImlucHV0IjoiPHA+KiBMaW5lcyAxLi41OiBMaW5lIGkgY29udGFpbnMgZml2ZSBzcGFjZS1zZXBhcmF0ZWQgdXBwZXItY2FzZSBsZXR0ZXJzIHRoYXQgYXJlIHJvdyBpPFwvcD5cclxuIiwib3V0cHV0IjoiPHA+KiBMaW5lIDE6IEEgc2luZ2xlIGludGVnZXIgdGhhdCBpcyB0aGUgbnVtYmVyIG9mIHdvcmRzIGluIHRoZSBkaWN0aW9uYXJ5IHRoYXQgY2FuIGJlIGZvcm1lZCB1c2luZyB0aGUgZGVzY3JpYmVkIHJ1bGVzPFwvcD5cclxuXHJcbjxwPiZuYnNwOzxcL3A+XHJcbiIsImhpbnQiOiIiLCJvcmlnaW5hbCI6IjEiLCJwcm9ibGVtX2xhbmdfY29kZSI6Ilx1YzYwMVx1YzViNCJ9XQ==

출처

Olympiad > USA Computing Olympiad > 2008-2009 Season > USACO February 2009 Contest > Bronze 3번

  • 문제를 번역한 사람: author6
  • 문제의 오타를 찾은 사람: isku