Spaces:
Sleeping
Sleeping
File size: 1,378 Bytes
7a8878c |
1 |
Nikita loves mountains and has finally decided to visit the Berlyand mountain range! The range was so beautiful that Nikita decided to capture it on a map. The map is a table of $$$n$$$ rows and $$$m$$$ columns, with each cell containing a non-negative integer representing the height of the mountain.He also noticed that mountains come in two types: With snowy caps. Without snowy caps. Nikita is a very pragmatic person. He wants the sum of the heights of the mountains with snowy caps to be equal to the sum of the heights of the mountains without them. He has arranged with the mayor of Berlyand, Polikarp Polikarpovich, to allow him to transform the landscape.Nikita can perform transformations on submatrices of size $$$k \times k$$$ as follows: he can add an integer constant $$$c$$$ to the heights of the mountains within this area, but the type of the mountain remains unchanged. Nikita can choose the constant $$$c$$$ independently for each transformation. Note that $$$c$$$ can be negative.Before making the transformations, Nikita asks you to find out if it is possible to achieve equality of the sums, or if it is impossible. It doesn't matter at what cost, even if the mountains turn into canyons and have negative heights.If only one type of mountain is represented on the map, then the sum of the heights of the other type of mountain is considered to be zero. |