Valid Chess Board
Practice
4.7 (6 votes)
Basic programming
Basics of implementation
Easy
Implementation
Math
Problem
56% Success 3080 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a tiled chart paper of $$N$$ rows and $$M$$ columns. There are a total of $$N \times M$$ tiles in it. Each tile is colored either black or white. Now, you need to count how many ways are there to cut valid chessboards of size $$8 \times 8$$ out of this chart paper. 

Notes

$$1$$. One chessboard is different from another if either of them contains at least one tile which is different from another chessboard.
$$2$$. The chess board formation should have distinct colors of adjacent cells i.e. Black$$/$$White alternative (regular chessboard rules apply).

Input Format

The first line contains two space-separated integers $$N$$ and $$M$$ as input.
In the next $$N$$ lines, you are given a string of $$M$$ characters. Each character is either $$0$$ or $$1$$. If it is $$0$$ then the tile color is white, if it is $$1$$ then the tile color is black.

Output Format

In the output, you need to print an integer that denotes the required count as stated in the problem statement.

Constraints

$$1 \le N , M \le 1000$$

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
58 votes
Tags:
ApprovedEasyImplementationOpen
Points:20
46 votes
Tags:
Basic ProgrammingEasy
3.War
Points:20
87 votes
Tags:
ApprovedBasic ProgrammingEasyOpen