P4431 [COCI 2017/2018 #2] Košnja
题目描述
**题目大意:**
给定一个$n*m$的矩阵,每次你可以选择前进一格或转弯(90度),求在不出这个矩阵的情况下遍历全部格点所需最少转弯次数。有多组数据
输入格式
第一行一个整数$k$,表示数据组数
以下$k$行,每行两个整数$n,m$,表示矩阵大小
输出格式
输出一个整数,即最少转弯次数
感谢@守望 提供翻译
说明/提示
In test cases worth 50% of total points, Mirko will see only one piece of land. The dimensions of this piece of land will be smaller than 500.
**Clarification of the first test case:**
The first piece of land can be mowed without making any turns if he starts from the field in the first column of the table, faced to the right and only going forwards. A similar idea applies for the second piece of land.