1982D — Beauty of the mountains

Правка en1, от TheEccentricDuck, 2024-12-18 16:31:59

Hi guys,

I just looked at the tutorial for this problem: https://mirror.codeforces.com/contest/1982/problem/D. I got all the steps correct (constructing a 2D prefix sum, finding the differences in the submatrices), but I was unable to see how to quickly determine a solution after this. In the tutorial, it states that it is sufficient to say that a solution exists if

$$$D \mod gcd(d_{1},d_{2},...,d_{q})=0$$$

where d[i] is the difference between capped and non-capped mountains in a k*k submatrix, and D is the difference of the total heights of capped and non-capped mountains; however, I cannot see why this is true. Could someone please help me by explaining a proof of this statement? Thank you very much everyone!

Теги help

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский TheEccentricDuck 2024-12-18 16:31:59 749 Initial revision (published)