기출 문제 / 삼성 2018 Second Half Morning Problem 2

Toast Egg Tray

You are given an n×n grid with 1×1 sized egg trays.

The amount of eggs in each tray is provided, and the trays are in a square shape. The four lines forming the tray can be separated.

When given an n×n grid with egg trays, follow these rules: