how to solve topcoder SRM 734 div 1 hard ?

could anyone explain how to solve topcoder SRM 734 div 1 hard ?
i have read the editorial but could not understand.
it has been mentioned in petr’s blog as very good dynamic programming problem.

what is the state of the dp ?
how to i move from one state to another ?

problem name: “TheRectangularcitydiv1”
problem link: https://community.topcoder.com/stat?c=problem_statement&pm=14901&rd=17158
editorial link: https://www.topcoder.com/blog/single-round-match-734-editorials/