| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 10 | 8 | 8 | 80.000% |
When botany proves too challenging, you can always switch to mycology – the study of mushrooms! As one of your first experiments, you plan to grow many mushrooms inside an infinitely large 2D exhibit, which can be modeled as a grid of tiles.
As it turns out, this specific species of mushroom that you are growing has a consistent shape. Each mushroom can be represented as a vertical stem (of any height) that is exactly one tile wide. Then, the very top tile in the stem juts outwards by one tile to the left, right, and up to form the cap of the mushroom. The cap of the mushroom must be completely above the ground. The figure below shows three such mushrooms:
Figure 1: A visualization of the first sample case.
You’ve noticed that for each mushroom to survive, two conditions must be met in your exhibit:
To make your exhibit more interesting, you’d like to grow mushrooms so that there exists an $r \times c$ rectangle in your exhibit where every tile is occupied by a mushroom. But in this exhibit, there is not much room for mushrooms. What is the minimum number of mushrooms needed to completely fill an $r \times c$ rectangle with mushrooms, assuming you can control the position and height of each mushroom you plant?
The first line of input contains two integers $r$ and $c$ ($1 \le r, c \le 1\, 000$), the number of rows and columns of the rectangle in your exhibit you want to completely fill with mushrooms.
Output a single integer, the minimum number of mushrooms that are needed to completely fill an $r \times c$ rectangle, or $-1$ if it is not possible.
2 3
2
4 1
1
100 100
-1
ICPC > Regionals > North America > Southeast USA Regional > 2025 Southeast USA Regional Programming Contest > Division 1 M번
ICPC > Regionals > North America > Southeast USA Regional > 2025 Southeast USA Regional Programming Contest > Division 2 M번
ICPC > Regionals > North America > South Central USA Regional > 2025 South Central USA Regional Contest > Division 1 M번
ICPC > Regionals > North America > South Central USA Regional > 2025 South Central USA Regional Contest > Division 2 M번
ICPC > Regionals > North America > Mid-Atlantic Regional > 2025 Mid-Atlantic USA Regional Contest > Division 1 M번
ICPC > Regionals > North America > Mid-Atlantic Regional > 2025 Mid-Atlantic USA Regional Contest > Division 2 M번