301735: CF329A. Purification
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Purification
题意翻译
翻译:你要净化一片大小为 $ n \times n $ 的土地。定义一次操作:你可以选一个不是 $ \texttt {E} $ 点的点,当你选择一个点时,与这个点的横坐标或纵坐标相等的点全被净化,每个点可以被净化多次,你要用最少的操作次数把这片土地净化完,输出所有你选择的点的坐标。 by [UID 593299](https://www.luogu.com.cn/user/593299)题目描述
You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an $ n×n $ grid. The rows are numbered $ 1 $ through $ n $ from top to bottom, and the columns are numbered $ 1 $ through $ n $ from left to right. At the far side of the room lies a door locked with evil magical forces. The following inscriptions are written on the door: The cleaning of all evil will awaken the door!Being a very senior adventurer, you immediately realize what this means. You notice that every single cell in the grid are initially evil. You should purify all of these cells. The only method of tile purification known to you is by casting the "Purification" spell. You cast this spell on a single tile — then, all cells that are located in the same row and all cells that are located in the same column as the selected tile become purified (including the selected tile)! It is allowed to purify a cell more than once. You would like to purify all $ n×n $ cells while minimizing the number of times you cast the "Purification" spell. This sounds very easy, but you just noticed that some tiles are particularly more evil than the other tiles. You cannot cast the "Purification" spell on those particularly more evil tiles, not even after they have been purified. They can still be purified if a cell sharing the same row or the same column gets selected by the "Purification" spell. Please find some way to purify all the cells with the minimum number of spells cast. Print -1 if there is no such way.输入输出格式
输入格式
The first line will contain a single integer $ n $ ( $ 1<=n<=100 $ ). Then, $ n $ lines follows, each contains $ n $ characters. The $ j $ -th character in the $ i $ -th row represents the cell located at row $ i $ and column $ j $ . It will be the character 'E' if it is a particularly more evil cell, and '.' otherwise.
输出格式
If there exists no way to purify all the cells, output -1. Otherwise, if your solution casts $ x $ "Purification" spells (where $ x $ is the minimum possible number of spells), output $ x $ lines. Each line should consist of two integers denoting the row and column numbers of the cell on which you should cast the "Purification" spell.
输入输出样例
输入样例 #1
3
.E.
E.E
.E.
输出样例 #1
1 1
2 2
3 3
输入样例 #2
3
EEE
E..
E.E
输出样例 #2
-1
输入样例 #3
5
EE.EE
E.EE.
E...E
.EE.E
EE.EE
输出样例 #3
3 3
1 3
2 2
4 4
5 3