Cultivation
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
In 21XX, the residents of the IOI planet plan to immigrate to a recently discovered planet. Thenewplanethasafield, whichisarectangulargridwith R rowsandC columns. Thecolumnsareparallelto the south-north direction, and the rows are parallel to the east-west direction. The cell in the i-th row from north and the j-th column from west is called the cell (i, j). The north-west corner of the field is the cell (1,1), and the south-east corner is the cell (R,C). In each year, the residents of the IOI planet choose the direction of the wind blowing on the field. The direction is one of east, west, south, or north. To engage in agriculture in the new planet, they will plant “JOI grasses” in all over the field in the new planet. In the spring of the first year of immigration, N cells in the field have JOI grasses. The range of JOI grasses are expanded by the wind. Each summer, the seeds of JOI grasses are blown by the wind to the direction chosen by the residents of the IOI planet. The seeds move one cell to the direction of the wind, and they land on. If the seeds land on a cell of the field without JOI grasses, it will have JOI grasses in the spring of the next year. Once a cell has JOI grasses, it will keep JOI grasses in the future. We want to calculate the minimum number of years until all the cells in the field have JOI grasses if we adjust the direction of the wind appropriately.