Codeforces Round 154 (Div. 2)
D
Table with Letters - 2
Codeforces
2000
原题
← CE →
翻译中…

Vasya has recently started to learn English. Now he needs to remember how to write English letters. He isn't sure about some of them, so he decided to train a little.

翻译中…

He found a sheet of squared paper and began writing arbitrary English letters there. In the end Vasya wrote $*n*$ lines containing $*m*$ characters each. Thus, he got a rectangular $*n* × *m*$ table, each cell of the table contained some English letter. Let's number the table rows from top to bottom with integers from 1 to $*n*$, and columns — from left to right with integers from 1 to $*m*$.

翻译中…

After that Vasya looked at the resulting rectangular table and wondered, how many subtables are there, that matches both following conditions:

翻译中…
  • the subtable contains at most $*k*$ cells with "a" letter;
  • all letters, located in all four corner cells of the subtable, are equal.
翻译中…

Formally, a subtable's definition is as follows. It is defined by four integers $*x*_{1}, *y*_{1}, *x*_{2}, *y*_{2}$ such that $1 ≤ *x*_{1} < *x*_{2} ≤ *n*$, $1 ≤ *y*_{1} < *y*_{2} ≤ *m*$. Then the subtable contains all such cells $(*x*, *y*)$ ($*x*$ is the row number, $*y*$ is the column number), for which the following inequality holds $*x*_{1} ≤ *x* ≤ *x*_{2}, *y*_{1} ≤ *y* ≤ *y*_{2}$. The corner cells of the table are cells $(*x*_{1}, *y*_{1})$, $(*x*_{1}, *y*_{2})$, $(*x*_{2}, *y*_{1})$, $(*x*_{2}, *y*_{2})$.

翻译中…

Vasya is already too tired after he's been writing letters to a piece of paper. That's why he asks you to count the value he is interested in.

翻译中…

Input

翻译中…

The first line contains three integers $*n*, *m*, *k*$ $(2 ≤ *n*, *m* ≤ 400; 0 ≤ *k* ≤ *n*·*m*)$.

翻译中…

Next $*n*$ lines contain $*m*$ characters each — the given table. Each character of the table is a lowercase English letter.

翻译中…

Output

翻译中…

Print a single integer — the number of required subtables.

翻译中…

Note

翻译中…

There are two suitable subtables in the first sample: the first one's upper left corner is cell $(2, 2)$ and lower right corner is cell $(3, 3)$, the second one's upper left corner is cell $(2, 1)$ and lower right corner is cell $(3, 4)$.

翻译中…

样例

Input #1
3 4 4
aabb
baab
baab
Output #1
2
InputCopy OutputCopy
Input #2
4 5 1
ababa
ccaca
ccacb
cbabc
Output #2
1
InputCopy OutputCopy
题目信息
题号
253D
时间限制
2 s
内存限制
256 MB
标签
暴力
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。