CF1404E Bricks

Description

A brick is defined as a rectangle with integer side lengths with either width $ 1 $ or height $ 1 $ (or both). There is an $ n\times m $ grid, and each cell is colored either black or white. A tiling is a way to place bricks onto the grid such that each black cell is covered by exactly one brick, and each white cell is not covered by any brick. In other words, bricks are placed on black cells only, cover all black cells, and no two bricks overlap. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1404E/050636f71672896c95a76cd68bdb315cb0256b57.png) An example tiling of the first test case using $ 5 $ bricks. It is possible to do better, using only $ 4 $ bricks. What is the minimum number of bricks required to make a valid tiling?

Input Format

N/A

Output Format

N/A

Explanation/Hint

The first test case can be tiled with $ 4 $ bricks placed vertically. The third test case can be tiled with $ 18 $ bricks like this: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1404E/e4a048c75957e1b968fc17253d618d87f8f324f8.png)