시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 128 MB312674641.071%

문제

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는 여기에 압축되어 있다.

W3sicHJvYmxlbV9pZCI6IjExNjUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIyZThcdWM1YjRcdWQzN2NcdWM5OTAiLCJkZXNjcmlwdGlvbiI6IjxwPjUgeCA1IFx1ZDU4OVx1YjgyY1x1YzVkMCBcdWIzMDBcdWJiMzhcdWM3OTAgXHVjNTRjXHVkMzBjXHViY2IzXHVjNzc0IFx1ZDU1OFx1YjA5OFx1YzUyOSBcdWI0ZTRcdWM1YjRcdWFjMDQgXHVkMzdjXHVjOTkwXHVjNzc0IFx1Yzc4OFx1YjJlNC4gXHVhZGY4XHViOWFjXHVhY2UwIFx1Yzc3NCBcdWQ1ODlcdWI4MmNcdWM1ZDBcdWMxMWMgXHVjOGZjXHVjNWI0XHVjOWM0IFx1YjJlOFx1YzViNFx1YjRlNFx1Yzc0NCBcdWNjM2VcdWIyOTQgXHVhYzgz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Mzk7cyBsZXR0ZXIgdHdpY2UgaW4gdGhlIHNhbWUgd29yZC48XC9wPlxyXG5cclxuPHA+Q291bnQgdGhlIG51bWJlciBvZiB3b3JkcyB0aGF0IGNhbiBiZSBmb3JtZWQgKGEgbnVtYmVyIHRoYXQgbWlnaHQgd2VsbCBiZSBzbWFsbGVyIHRoYW4gdGhlIG51bWJlciBvZiB3YXlzIGEgd29yZCBhIGNhbiBiZSBmb3JtZWQgc2luY2Ugd29yZHMgbWlnaHQgYmUgZm9ybWVkIGluIG1vcmUgdGhhbiBvbmUgd2F5KS48XC9wPlxyXG4iLCJpbnB1dCI6Ijx1bD5cclxuXHQ8bGk+TGluZXMgMS4uNTogTGluZSBpIGNvbnRhaW5zIGZpdmUgc3BhY2Utc2VwYXJhdGVkIHVwcGVyLWNhc2UgbGV0dGVycyB0aGF0IGFyZSByb3cgaTxcL2xpPlxyXG48XC91bD5cclxuIiwib3V0cHV0IjoiPHVsPlxyXG5cdDxsaT5MaW5lIDE6IEEgc2luZ2xlIGludGVnZXIgdGhhdCBpcyB0aGUgbnVtYmVyIG9mIHdvcmRzIGluIHRoZSBkaWN0aW9uYXJ5IHRoYXQgY2FuIGJlIGZvcm1lZCB1c2luZyB0aGUgZGVzY3JpYmVkIHJ1bGVzPFwvbGk+XHJcbjxcL3VsPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwiaHRtbF90aXRsZSI6IjAiLCJwcm9ibGVtX2xhbmdfdGNvZGUiOiJFbmdsaXNoIn1d

출처

Olympiad > USA Computing Olympiad > 2008-2009 Season > USACO February 2009 Contest > Bronze 3번 (수정)

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

채점 및 기타 정보

  • 소스 코드의 크기는 65536B을 넘을 수 없다.