309231: CF1647C. Madoka and Childish Pranks
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Madoka and Childish Pranks
题意翻译
给定一个 01 矩阵,其中 0 代表黑色,1 代表白色 Madoka 要对一个同样大小的 0 矩阵染色,每次染色可以将一个矩形染成国际象棋的颜色 现在问能否染成给定的 01 矩阵,如果可以,输出方案题目描述
Madoka as a child was an extremely capricious girl, and one of her favorite pranks was drawing on her wall. According to Madoka's memories, the wall was a table of $ n $ rows and $ m $ columns, consisting only of zeroes and ones. The coordinate of the cell in the $ i $ -th row and the $ j $ -th column ( $ 1 \le i \le n $ , $ 1 \le j \le m $ ) is $ (i, j) $ . One day she saw a picture "Mahou Shoujo Madoka Magica" and decided to draw it on her wall. Initially, the Madoka's table is a table of size $ n \times m $ filled with zeroes. Then she applies the following operation any number of times: Madoka selects any rectangular subtable of the table and paints it in a chess coloring (the upper left corner of the subtable always has the color $ 0 $ ). Note that some cells may be colored several times. In this case, the final color of the cell is equal to the color obtained during the last repainting. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1647C/382bdf687e9360fce9f9a4f6fec3edc2a2101bb5.png)White color means $ 0 $ , black means $ 1 $ . So, for example, the table in the first picture is painted in a chess coloring, and the others are not.For better understanding of the statement, we recommend you to read the explanation of the first test. Help Madoka and find some sequence of no more than $ n \cdot m $ operations that allows you to obtain the picture she wants, or determine that this is impossible.输入输出格式
输入格式
Each test contains multiple test cases. The first line contains a single integer $ t $ ( $ 1 \le t \le 10 $ ) — the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $ n $ and $ m $ ( $ 1 \leq n, m \leq 100 $ ) — the size of the table. Each of the following $ n $ lines contains a string of length $ m $ consisting only of $ 1 $ and $ 0 $ — description of the picture that Madoka wants to obtain.
输出格式
If it is impossible to obtain the given picture, print $ -1 $ . Otherwise, print in the first line a single integer $ q $ ( $ 0 \leq q \leq n \cdot m $ ) — the number of operations you need to obtain the picture. Note that you do not need to minimize the number of operations. Then for each operation (in the order of execution) print a single line containing four numbers — the coordinates of the upper-left corner and the lower-right corner of the rectangle.
输入输出样例
输入样例 #1
4
4 5
01000
10100
01010
00110
2 3
001
010
3 3
110
101
000
1 1
0
输出样例 #1
4
1 1 3 3
3 3 4 4
4 3 4 4
4 2 4 3
1
1 2 2 3
-1
0