#Lutece2707. Magic Horse
Magic Horse
Migrated from Lutece 2707 Magic Horse
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There is a grid with rows and columns of cells. Each cell is initially white. Little horse wants to dye all the white cells black.
Little Horse has learned magic from Little Rabbit, which can help him dye the cells. But Little Horse is not yet skilled in using magic, so his magic is somehow restricted: if he wants to dye a cell, at least of the cells adjacent to it must be black. Two cells are adjacent if they share a common edge.
Obviously, when there are no black cells in the grid, Little Horse cannot even dye a single cell. So Little Horse invites Little Rabbit to help him dye some cells beforehand, as Little Rabbit has stronger magic to dye the cells without restriction.
Little Rabbit is reluctant to use too much magic. So he wants to know how many cells he needs to dye at least so that Little Horse can dye all the cells black.
Input
Two integers (), denoting the number of rows and columns of the grid.
Output
The number of cells Little Rabbit needs to dye at least.
Samples
3 3
5
Constraints
When , here is a method for Little Rabbit to dye the cells.
After that, Little Horse can dye the remaining cells in the following order.
Resources
电子科技大学第十二届 ACM 趣味程序设计竞赛