Here is the spoj (krect) issue that states
Given the square of the square M * N. Each square contains the letter of the English alphabet ('A' .. 'Z').The K-rectangle of the board is a rectangle whose sides are parallel to the sides of the board and contain exactly K different types of lettersFor example, with this 4 * 3 board:CEDCEBCBCDDAThe rectangle [(1,1), (2,2)] is a 2-rectangle of the board, as it contains two different letters: C and E.For M, N, K and the M * N board. Determine how many K-rectangles are on the board.
Given the square of the square M * N. Each square contains the letter of the English alphabet ('A' .. 'Z').
The K-rectangle of the board is a rectangle whose sides are parallel to the sides of the board and contain exactly K different types of letters
For example, with this 4 * 3 board:
CEDCEBCBCDDA
The rectangle [(1,1), (2,2)] is a 2-rectangle of the board, as it contains two different letters: C and E.
For M, N, K and the M * N board. Determine how many K-rectangles are on the board.
Can you offer any solution? All ideas are welcome.
, , , 25502500 100x100. , , K K-, K K-.
, -, , O (n ^ 4) , . , , , K = 6, , 6. 2D- , .
1 x .....6 2 x ..3 3 x .2 4 x .2 5 x .2 6 x 1
K , , , , .
, :
50 * 50 * 100 ( ) + 100 * 100 * 2 (/ ) + 100 * 100 * 26 ( ) = 530 000 . , "" , 100 * 100 + 100 * 100 * 2 + 100 * 100 * 26 = 290 000 , .
O (a * n ^ 3). a - .
:
( ) . O (n ^ 3). . . , (j, k), , (j-1, k) (j, k-1).
. , .
http://apps.topcoder.com/forums/;jsessionid=662C6CE6626AB8343C7C018332CBF23D?module=Thread&threadID=666525&start=0&mc=8#1208270