Problem B
Dandelions
Languages
en
sv
During his youth, Gösta was quite fond of dandelion soda.
Unfortunately, it’s not popular at all anymore. In his older
age, Gösta has become quite wealthy, and now he wants to use
his fortune to open a business selling dandelion soda. To do
this, he will obviously need a lot of dandelions. He has a
meadow that is
Currently, there are dandelions growing in
Input
The first line contains the integers
Following that is a line with the integer
The next
Output
Print an integer: the minimum number of years to fill the entire meadow with dandelions if the wind directions are chosen optimally.
Scoring
Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.
Group |
Point value |
Constraints |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
No additional constraints. |
Explanation of sample 1:
Initially, there are dandelions on the following squares:
![\includegraphics[width=0.8\textwidth ]{t0.png}](/problems/maskrosor/file/statement/en/img-0001.png)
If we blow the wind from the south, the dandelions spread to the west:
![\includegraphics[width=0.8\textwidth ]{t1.png}](/problems/maskrosor/file/statement/en/img-0002.png)
If we then blow the wind from the north, the dandelions spread southward:
![\includegraphics[width=0.8\textwidth ]{t2.png}](/problems/maskrosor/file/statement/en/img-0003.png)
If we blow the wind from the north once again, the entire meadow will be filled.
![\includegraphics[width=0.8\textwidth ]{t3.png}](/problems/maskrosor/file/statement/en/img-0004.png)
Sample Input 1 | Sample Output 1 |
---|---|
3 4 3 1 2 1 4 2 3 |
3 |
Sample Input 2 | Sample Output 2 |
---|---|
4 4 4 1 1 1 4 4 1 4 4 |
4 |