You are given a $n\times n$ rectangular grid of squares. You want to color some cells to black, such that
- Black cells do not touch each other orthogonally(they do not share a side).
- We can draw a single continuous non-intersecting loop that passes through each cell that is not black. The loop must "enter" each cell from the centre of one of its four sides and "exit" from a different side; all turns are 90 degrees.
The following is an example.
In this problem, the weight of cells $(i,j) (1\leq i,j \leq n)$ is $w_{i,j}$. You want to color some cells black, and maximize the sum of weights of these cells.