How to count number of all rectangle that contain all the same number in matrix

Revision en2, by ProblemAsker, 2020-06-11 17:34:04

There are n*m matrix (n,m<=1000) each element in the matrix are between 1 and 1e9 Count number of all rectangle in matrix that contain all the same element

how to solve this? I have been thinking for 2 days. Thank you very much.

Example:

Input:

2 3

1 1 2

1 1 2

output : 12

Tags #dynamic programing, #math

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English ProblemAsker 2020-06-11 17:34:04 9
en1 English ProblemAsker 2020-06-11 17:22:04 368 Initial revision (published)