#ABC109D. [ABC109D] Make Them Even
[ABC109D] Make Them Even
Score : points
Problem Statement
There is a grid of square cells with horizontal rows and vertical columns. The cell at the -th row and the -th column will be denoted as Cell .
In Cell , coins are placed.
You can perform the following operation any number of times:
Operation: Choose a cell that was not chosen before and contains one or more coins, then move one of those coins to a vertically or horizontally adjacent cell.
Maximize the number of cells containing an even number of coins.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print a sequence of operations that maximizes the number of cells containing an even number of coins, in the following format:
That is, in the first line, print an integer between and (inclusive), representing the number of operations.
In the -th line (), print four integers and ( and ), representing the -th operation. These four integers represents the operation of moving one of the coins placed in Cell to a vertically or horizontally adjacent cell, .
Note that if the specified operation violates the specification in the problem statement or the output format is invalid, it will result in Wrong Answer.
Every cell contains an even number of coins after the following sequence of operations:
- Move the coin in Cell to Cell .
- Move the coin in Cell to Cell .
- Move one of the coins in Cell to Cell .