CF1647C.Madoka and Childish Pranks
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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≤i≤n, 1≤j≤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×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.
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⋅m operations that allows you to obtain the picture she wants, or determine that this is impossible.
小时候的麻美是个极其任性的女孩,她最喜欢的恶作剧之一就是在墙上涂画。据麻美的回忆,那面墙是一个 n 行 m 列的表格,仅由数字 0 和 1 构成。第 i 行第 j 列(其中 1≤i≤n,1≤j≤m)的单元格坐标为 (i,j)。
有一天,她看到了一幅《魔法少女小圆》的画,便决定把它画在自己的墙上。最初,麻美的表格是一个大小为 n×m、全部填满 0 的表格。随后,她可以任意多次执行如下操作:
麻美任选表格中的一个矩形子区域,并以“棋盘着色”方式为其上色(该子区域左上角单元格的颜色始终为 0)。注意,某些单元格可能被多次上色;此时,该单元格的最终颜色等于最后一次重绘时所赋予的颜色。
白色表示 0,黑色表示 1。例如,第一张图中的表格是按棋盘方式着色的,而其余图则不是。
为更好理解题意,我们建议您阅读第一个测试用例的说明。
请帮助麻美找出一个最多包含 n⋅m 次操作的操作序列,使得最终能得到她想要的图案;若不可能实现,则判定其不可行。
输入格式
Each test contains multiple test cases. The first line contains a single integer t (1≤t≤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≤n,m≤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.
每个测试包含多个测试用例。第一行包含一个整数 t(1≤t≤10)—— 测试用例的数量。随后是各测试用例的描述。
每个测试用例的第一行包含两个整数 n 和 m(1≤n,m≤100)—— 表格的尺寸。接下来的 n 行中,每行包含一个长度为 m 的字符串,该字符串仅由字符 1 和 0 组成 —— 描述了麻陶希望得到的图案。
输出格式
If it is impossible to obtain the given picture, print −1.
Otherwise, print in the first line a single integer q (0≤q≤n⋅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。
否则,在第一行输出一个整数 q(0≤q≤n⋅m),表示得到该图片所需的操作次数。注意:你无需最小化操作次数。
然后,对每个操作(按执行顺序),在一行中输出四个数字——矩形左上角和右下角的坐标。
输入输出样例
输入#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
说明/提示
The description of the first test case is below.

In the third test case, it is impossible to paint the desired picture.
In the fourth test case, the initial table is already the desired picture.
第一个测试用例的描述如下。

在第三个测试用例中,无法绘制出目标图案。
在第四个测试用例中,初始表格已与目标图案一致。
输入解题思路,AI测评打分。不知道怎么写?