




Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Think of a greedy method.
First, distribute the rooks in individual rows.
You can do this by sorting all rooks by their rows. Then assign the first one to the first row, the second one to the second row, and so on.
After you've distributed rooks across all rows, now do the same for columns.
Sort rooks by their columns and then assign the first one to the first column and so on.