시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 171 65 59 42.143%

문제

상근이와 창영이는 트리플렛이라는 게임을 하고 있다. 이 게임을 하려면 칠판에 N*N 그리드를 그려야 한다. 그 다음 알파벳 대문자를 적절히 각 칸에 써 넣는다. 한 알파벳을 여러 칸에 쓸 수는 없다.

여기까지는 게임을 하기 위해 준비하는 과정이다. 트리플렛의 목표는 직선을 이루는 세 글자를 되도록 많이 찾는 것이다. 세 글자가 직선을 이루려면, 글자가 있는 칸의 중심을 연결한 선이 선분이어야 한다.

칠판에 그린 그리드의 상태가 주어졌을 때, 직선을 이루는 세 글자(트리플렛)의 개수를 찾는 프로그램을 작성하시오.

입력

첫째 줄에 그리드의 크기 N이 주어진다. (3 ≤ N ≤ 100)

다음 N개 줄에는 그리드에 채워져 있는 글자가 주어진다. 글자를 채우지 않은 빈 칸의 경우에는 '.'로 주어진다.

출력

첫째 줄에 트리플렛의 개수를 출력한다.

예제 입력 1

4
...D
..C.
.B..
A...

예제 출력 1

4
W3sicHJvYmxlbV9pZCI6IjMwNDIiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQyYjhcdWI5YWNcdWQ1MGNcdWI4MWIiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzBjMVx1YWRmY1x1Yzc3NFx1YzY0MCBcdWNjM2RcdWM2MDFcdWM3NzRcdWIyOTQgXHVkMmI4XHViOWFjXHVkNTBjXHViODFiXHVjNzc0XHViNzdjXHViMjk0IFx1YWM4Y1x1Yzc4NFx1Yzc0NCBcdWQ1NThcdWFjZTAgXHVjNzg4XHViMmU0LiBcdWM3NzQgXHVhYzhjXHVjNzg0XHVjNzQ0IFx1ZDU1OFx1YjgyNFx1YmE3NCBcdWNlNjBcdWQzMTBcdWM1ZDAgTipOIFx1YWRmOFx1YjlhY1x1YjRkY1x1Yjk3YyBcdWFkZjhcdWI4MjRcdWM1N2MgXHVkNTVjXHViMmU0LiBcdWFkZjggXHViMmU0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