#P1380. Maximum Non-overlapping T-Pentomino Placement

    ID: 14667 Type: Default 1000ms 256MiB

Maximum Non-overlapping T-Pentomino Placement

Maximum Non-overlapping T-Pentomino Placement

You are given a chessboard of size \(n \times m\). You need to place as many non-overlapping T-pentominoes as possible on the board. The T-pentomino can be rotated, and the four possible orientations are given below (each '#' represents a cell occupied by the T-pentomino, and each '.' represents an empty cell):

###      ..#      .#.      #..
.#.      ###      .#.      ###
.#.      ..#      ###      #..

Each T-pentomino covers exactly 5 cells. Note that in every orientation, the minimal bounding box of the piece is \(3\times3\). Therefore, if either \(n\) or \(m\) is less than 3, you cannot place any T-pentomino.

Your task is to determine the maximum number of T-pentominoes that can be placed on an \(n \times m\) board without overlapping. A simple observation is that if \(n \ge 3\) and \(m \ge 3\), an upper bound is \(\lfloor\frac{nm}{5}\rfloor\) since each piece uses 5 cells. It turns out that this bound is achievable for all boards with \(n, m \ge 3\>.

Input Constraints: \(n\) and \(m\) are positive integers. You may assume that \(n\) and \(m\) are within reasonable limits so that a simple arithmetic calculation will complete within the time limits.

inputFormat

The input consists of a single line containing two integers \(n\) and \(m\), representing the dimensions of the chessboard.

n m

outputFormat

Output a single integer -- the maximum number of non-overlapping T-pentominoes that can be placed on the board.

sample

3 3
1