#976. [NEERC2014] Alter Board

[NEERC2014] Alter Board

题目描述

Little Dima gave his little brother Petya interactive chess board of size n×mn \times m as a present. There are many awesome features of this board but one is Petya's favorite. He can choose any rectangle formed by board squares and perform an inversion. Every white cell in the inverted rectangle becomes black and every black one becomes white.

In the initial state the board is colored in chess style, namely every cell is either black or white and every two cells that share a side have different colors. Little Petya wants to perform several inversions described above to turn all cells into the same color. He is impatient, so he asks you to provide him with instructions to do it with the minimal number of inversions.

输入格式

Contains two integers nn and m(1n,m50)m (1 \le n , m \le 50) - the number of rows and columns on the board, respectively.

输出格式

The first line must contain the number of inversions kk required to transform the board.

The following kk lines must describe inversions, one per line. Each line must contains 44 integers - row and column of one of the corners of the corresponding rectangle and row and column of the opposite corner. Any two opposite corners can be used to specify a rectangle.

Rows of the board are numbered from 11 to nn . Columns of the board are numbered from 11 to mm .

题目大意

给出了一个 nnmm 列的国际象棋棋盘。每次可以选择一个矩形区域,将里面的所有格子的颜色翻转。问最少需要多少次才能让所有格子变成同色?请输出一组合法的翻转方案。

2 2

2
1 1 1 1
2 2 2 2

提示

Time limit: 1 s, Memory limit: 256 MB.

spj provider:

/user/137367