7056.Coin Grid

Time Limit: 1s Memory Limit: 512MB

There is an $n \times n$ grid whose each square is empty or has a coin. On each move, you can remove all coins in a row or column.

What is the minimum number of moves after which the grid is empty?

Input Format(From the terminal/stdin)

The first input line has an integer $n$ : the size of the grid. The rows and columns are numbered $1,2,\dots,n$ .

After this, there are $n$ lines describing the grid. Each line has $n$ characters: each character is either . (empty) or o (coin).

  • $1 \le n \le 100$

Output Format(To the terminal/stdout)

First print an integer $k$ : the minimum number of moves. After this, print $k$ lines describing the moves.

On each line, first print $1$ (row) or $2$ (column), and then the number of a row or column. You can print any valid solution.

Sample Input

Copy
3
..o
o.o
...
 \n
   \n
   \n
   \n

Sample Output special judge

Copy
2
1 2
2 3
 \n
 · \n
 · \n
Source: CSES, Additional Problems II, 1709

Submit

请先 登录

© 2025 FAQs