Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
For each cell, it has 3 options, either it is empty, or contains an introvert, or an extrovert.
You can do DP where you maintain the state of the previous row, the number of remaining introverts and extroverts, the current row and column, and try the 3 options for each cell.
Assume that the previous columns in the current row already belong to the previous row.