JOIN
Get Time

   Problem Statement  

 Problem Statement for TheTilesDivOne

Problem Statement

    John and Brus have a rectangular chessboard with black and white tiles. Rows and columns of the chessboard are numbered starting from 0. The cell at row i, column j is black if i+j is even and it is white if i+j is odd.



Some of the cells of the chessboard are occupied by chess pieces. You are given a String[] board. For each i and j, the j-th character of the i-th element (0-based indices) of board is 'X' if the cell in row i, column j of the chessboard contains a chess piece. Otherwise, the j-th character of the i-th element of board is '.'.



John and Brus also have an infinite supply of L-shaped tiles. Each tile consists of three squares which are of the same size as the cells of the chessboard. I.e., each tile looks as follows:
OO
O
John and Brus want to place some of the tiles onto their chessboard, according to the following rules:
  • Each tile may be rotated by any multiple of 90 degrees.
  • Each tile must cover exactly three cells of the chessboard.
  • Tiles are not allowed to overlap.
  • Tiles are not allowed to cover the cells that are already occupied by the chess pieces.
  • The corner cell of each tile must cover a black cell of the chessboard.




Return the maximum number of tiles John and Brus can place on the board according to the above rules.
 

Definition

    
Class:TheTilesDivOne
Method:find
Parameters:String[]
Returns:int
Method signature:int find(String[] board)
(be sure your method is public)
    
 

Constraints

-board will contain between 1 and 47 elements, inclusive.
-Each element of board will contain between 1 and 47 characters, inclusive.
-All elements of board will contain the same number of characters.
-Each element of board will consist of only characters 'X' and '.'.
 

Examples

0)
    
{"X.X",
 "...",
 "X.X"}
Returns: 1
Since only one black cell is available, just one tile can be placed on the board.
1)
    
{"...",
 "...",
 "..."}
Returns: 2
2)
    
{"......X.X.XXX.X.XX."}
Returns: 0
3)
    
{"X.....XXX.XX..XXXXXXXXX...X.XX.XX....X",
 ".XXXX..X..XXXXXXXX....XX.X.X.X.....XXX",
 "....XX....X.XX..X.X...XX.X..XXXXXXX..X",
 "XX.XXXXX.X.X..X..XX.XXX..XX...XXX.X..."}
Returns: 13

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.

This problem was used for:
       Single Round Match 575 Round 1 - Division I, Level Three