KRECT - Counting K-Rectangle

Given a M×N square board. Each square contains a letter of the English alphabet ('A' .. 'Z').

A K-rectangle of the board is a rectangle whose sides are parallel to the sides of the board, and contains exactly K different types of letter.

For example, with this 4×3 board:

CED
CEB
CBC
DDA

The rectangle [(1,1), (2, 2)] is a 2-rectangle of the board because it contains 2 different letters: C and E.

Given M, N, K and the M×N board. Determine how many K-rectangles there are in the board.

Input

The first line contains 3 integers M, N and K. (1 ≤ M, N ≤ 100, 1 ≤ K ≤ 26)

The following M lines, each contains N letters of the English alphabet ('A' .. 'Z')

Output

Write one integer - the number of K-rectangles in the given board.

Example

Input:
4 3 3
CED
CEB
CBC
DDA

Output:
12

Được gửi lên bởi:Race with time
Ngày:2009-05-05
Thời gian chạy:1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:Based on problem CRECT - @vnoi

hide comments
2020-03-16 17:50:50
Bài dễ quá. Tại code sai mấy đấm mới AC :(
2020-03-16 17:43:18
1 đấm ac
2018-06-15 11:11:15
k hieu sao bai crect thi k tle nhung bai nay thi ac trong khi lam cung thuat toan
2012-03-20 13:27:50 english
chán quá TLE hoài..chạy ở máy nhà tất cả các test max đều có 0.3s..hjx
edit: đã AC sau 1 hồi tối ưu mãi..:D

Last edit: 2012-03-20 14:11:28
2011-12-10 09:08:40 Cao Viên Viên
Liệu anh có thể để time limit nới ra khoảng 3s được không ạ !

Last edit: 2011-12-10 09:08:59
2011-08-10 04:53:49 Cao Viên Viên
time chặt quá :(((((((((((((((
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.