Official algorithmic problem description and constraints.
You are given an integer π. You choose π cells (π₯1,π¦1),(π₯2,π¦2),β¦,(π₯π,π¦π) in the grid πΓπ where 1β€π₯πβ€π and 1β€π¦πβ€π.
Let ξ΄ be the set of distinct Manhattan distances between any pair of cells. Your task is to maximize the size of ξ΄. Examples of sets and their construction are given in the notes.
If there exists more than one solution, you are allowed to output any.
Manhattan distance between cells (π₯1,π¦1) and (π₯2,π¦2) equals |π₯1βπ₯2|+|π¦1βπ¦2|.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.