[using C++]Masterchef Daniel recently baked a big pizza that can be represented as a grid of N rows and M columns, each cell can be either empty or contain a jalapeno, Daniel wants to cut out a sub-rectangle from the pizza which contains even number of jalapenos. Before cutting such a sub-rectangle, he is interested in knowing how many sub-rectangles are there which contains even number of jalapenos. First line of input consist of two integers P and Q. Each of the next P lines contains a string of length Q, j-th character of i-th string is 1 if the corresponding cell contains a jalapeno otherwise it's 0. Output a single integer, the number of sub rectangles which contains even number of jalapeno. Sample Input: 2 2 21 01 Output: 5
[using C++]Masterchef Daniel recently baked a big pizza that can be represented as a grid of N rows and M columns, each cell can be either empty or contain a jalapeno, Daniel wants to cut out a sub-rectangle from the pizza which contains even number of jalapenos. Before cutting such a sub-rectangle, he is interested in knowing how many sub-rectangles are there which contains even number of jalapenos.
First line of input consist of two integers P and Q. Each of the next P lines contains a string of length Q, j-th character of i-th string is 1 if the corresponding cell contains a jalapeno otherwise it's 0.
Output a single integer, the number of sub rectangles which contains even number of jalapeno.
Sample Input:
2 2
21
01
Output:
5
Step by step
Solved in 3 steps with 1 images