Logo
(追記) (追記ここまで)

16703번 - Matrice 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB79676289.855%

문제

Agent Sue Thomas and her son are looking for trinities in a grid. The word trinity is a neologism referring to a particular triangular (as the morpheme “tri” suggests) shape composed of cells in the grid.

Each trinity is a result of taking a square-shaped area of the cells and removing all cells that lie either above or below one of the two diagonals of the area. The diagonal may be either the main diagonal (southeast-northwest direction) or the main antidiagonal (southwest-northeast direction). A valid trinity consists of at least three grid cells and all its cells contain the same character.

입력

The first input line contains two numbers N and M (1 ≤ N, M ≤ 1000), describing the number of rows and columns in the grid, respectively. Each of next N lines contains M characters, whose ASCII codes are between 33 and 126, inclusively.

출력

Output the number of different valid trinities in the input grid.

제한

예제 입력 1

2 2
AA
Ad

예제 출력 1

1

예제 입력 2

5 5
#####
####.
###..
##...
#....

예제 출력 2

60

예제 입력 3

5 4
hwwr
eahe
lroy
lswo
oaau

예제 출력 3

0

예제 입력 4

5 6
#girls
##areb
#.#est
#..#!!
#####!

예제 출력 4

7

힌트

출처

ICPC > Regionals > Europe > Central European Regional Contest > CERC 2018 M번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /