기출 문제 / 삼성 2021 First Half Morning Problem 1

Amusement Ride Boarding

We are planning to board ( n \times n ) students onto an amusement ride shaped like an ( n \times n ) grid in sequence. Initially, all cells of the ride are empty. ((r, c)) denotes the cell at row ( r ) and column ( c ).

Each student has exactly 4 favorite students.