Problem Statement | |||||||||||||
NOTE: This problem statement contains images that may not display properly if viewed outside of the applet. Howard Benson loves puzzles and is always eager to invent new ones. He has recently invented a new puzzle based on the old puzzles that involved placing various tetrominoes inside a rectangle. For this puzzle, Howard picked four kinds of tetrominoes and made pieces with their shapes. The player can use as many pieces of each kind as necessary. The pieces he made available are shown in the following image: Another component of the puzzle is the board, which is a square grid composed of white and black cells. The objective of the game is to cover all the white cells by placing a minimum number of pieces on the board. There are many rules regarding the placement of the pieces:
For example, the following picture shows a board configuration and a solution using a minimum number of pieces: You are given the board as a String[] board. The j-th character of the i-th element of board is 'X' if the cell at column j, row i is black and '.' if the cell is white. Return the minimum number of shapes that are required to cover all the white cells by following the aforementioned rules. If it is impossible to cover all the white cells following the rules, return -1. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | board will contain between 1 and 22 elements, inclusive. | ||||||||||||
- | Each element of board will contain between 1 and 22 characters, inclusive. | ||||||||||||
- | All elements of board will contain the same number of characters. | ||||||||||||
- | Each element of board will contain only the characters '.' and uppercase 'X'. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|