Problem Description
Loading...
Problem Analysis
At first I didn’t understand why the bottom-left and top-right blocks were constrained
until I realized
it means every 2×2 must equal the top-left 2×2
In the 3×3 grid
x a x
b x c
x d x
the middle cell is shared by all four 2×2 blocks and does not need to be considered
so we can enumerate the number in the top-left block
and calculate how many possibilities each of the other three blocks has
It cannot be calculated directly because
some numbers may make the conditions impossible to satisfy
(adding 1 to the other cells still gives a sum larger than the top-left one)
(adding n to the other cells still does not give a sum larger than the top-left one)
Also note the data range__int64 is required
cpp
| |
Problem address: 【CodeForces】[675B]Restoring Painting