영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
시간 제한 1초 · 메모리 제한 512 MB
Problem
You are given a grid of letters. Your task is to calculate, for each letter, the number of square subgrids whose each letter is the same.
Input
The first line has two integers n and k: the size of the grid and the number of letters. The letters are the first k uppercase letters.
After this, there are n lines that describe the grid. Each line has n letters.
Output
Print k lines: for each letter, the number of subgrids.
Constraints
- 1 ≤ n ≤ 3000
- 1 ≤ k ≤ 26
예제
예제 1
5 3 ABBBC BBBBC BCAAA AAAAA AAAAA
21 10 3