A Complex Matrix Count
Tag(s):

Problem
Editorial
Analytics

You will be given a matrix of size $N × M$, and you need to count the number of submatrices which has atleast K occurrences of X and atleast two corner elements equal. These submatrices should have minimum two rows and two columns.

Input:
First line of the input contains four space separated integers, N, M, K and X respectively.
Next N lines contain M space separated integers denoting the matrix

Output:
Output a single line containing the answer.

Constraints:

• $1 ≤ N, M ≤ 100$
• $1 ≤ K ≤ 20$
• $1 ≤ X ≤ 100$
• $1 ≤ A_{i,j} ≤ 100$

SAMPLE INPUT
3 3 2 1
1 2 3
1 3 6
22 1 33

SAMPLE OUTPUT
4

Explanation

Here, the four submatrices are :-

1. 1 2
1 3
2. 1 2 3
1 3 6
3. 1 2
1 3
22 1
4. 1 3
22 1
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...