|| ||Code Submission Evaluation System
CSES - HIIT Open 2018
HIIT Open 2018
|Contest start:||2018-05-26 11:00:00|
|Contest end:||2018-05-26 16:00:00|
Task list | Submit code | Submissions | Messages | Scoreboard | Statistics
There is an $n \times n$ grid whose each square is initially white. On each move you can paint one row or column black.
Your task is to create a given target grid
using the minimum number of moves.
The first input line has an integer $n$: the size of the grid.
After this, there are $n$ lines of $n$ characters that describe the target grid. Each color is 0 (white) or 1 (black).
Print the minimum number of moves needed. If the task is impossible, print $-1$.