#P14743. [ICPC 2021 Seoul R] Squid Game

[ICPC 2021 Seoul R] Squid Game

题目描述

:::align{center} :::

You are one of the 456456 players participating in a series of children's games with deadly penalties. Passing through a number of maze-like hallways and stairways, you have opened the gate of the next game. There are three buckets with infinite capacity, each of which contains an integral number of liters of water. The buckets are numbered from 11 to 33. The amounts of water initially contained in buckets 11, 22, and 33 are given as XX, YY, and ZZ, respectively.

At any time, you can double the amount of one bucket by pouring into it from another one. Specifically, you can pour from a bucket of yy liters into one of xx (xyx \leq y) liters until the latter contains 2x2x liters and the former does yxy - x liters. Note that xx and yy are always integers and xyx \leq y. See the Figure J.1.

:::align{center}

Figure J.1 A process of pouring :::

In order to survive, you have to empty one of the buckets in a limited number of pouring. Fortunately, it is always possible to empty one of the buckets. Given the initial amounts XX, YY, and ZZ of water in three buckets, write a program to output a sequence of pouring until one of the buckets is empty for the first time.

输入格式

Your program is to read from standard input. The input starts with a line containing three integers XX, YY, and ZZ (1XYZ1091 \leq X \leq Y \leq Z \leq 10^9), representing the initial amounts of water in buckets 11, 22, and 33, respectively.

输出格式

Your program is to write to standard output. The first line should contain the number mm of pouring until one of the buckets is empty for the first time. The number mm should be no more than 1,0001,000. Each of the following mm lines contains two integers AA and BB (1AB31 \leq A \neq B \leq 3), which means you pour from bucket AA into bucket BB in a process of pouring. You should guarantee that one of buckets is empty for the first time after the mm pouring. If there are several ways to empty one of the buckets, then print one of them.

1 2 3
2
3 2
3 1
1 4 6
3
2 1
3 1
1 3