Orange Revolution
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
In Sykhiv live voters of three parties — orange, blue, and red. When voters of two different parties meet, in the process of an argument they change their political choice in favor of the third party, and also invite \(k\) new voters, who will also support the third party. When voters of the same party meet, nothing happens.
If all existing voters become supporters of the orange party, it will be considered that the Orange Revolution has occurred in Sykhiv. The Kyiv Beekeepers Organization is interested in making the Orange Revolution happen and has invited you as a leading political consultant to determine whether it is possible to organize a certain set of meetings between voters so that the Orange Revolution occurs?
Input
The first line contains three numbers \(a\), \(b\), \(c\) separated by a space — the number of voters of the orange, blue, and red parties, respectively. The second line contains the number \(k\) — how many new voters will be invited as a result of a meeting.
Output
Output YES if the Orange Revolution can be organized and
NO if not. In case it can be organized, on the second line
output \(t\) — the number of meetings
you will plan. In the next \(t\) lines,
output two characters separated by a space — the party affiliation
labels of the voters who will meet. By the characters O,
B, R we denote the orange, blue, and red
parties, respectively. The number of meetings you propose must not
exceed \(10^5\) (the budget is
limited). If there are several options for conducting meetings, output
any of them.
Constraints
\(2 \leq a, b, c \leq 10^4\),
\(1 \leq k \leq 10^4\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 3 2 2 2 | YES 2 B R B R |
| Input (stdin) | Output (stdout) |
|---|---|
| 17 7 4 3 | NO |
Notes
In the first test, we twice organize meetings between blue and red voters and the quantities will change as follows: 3,2,2 -> 7,1,1 -> 11,0,0. Let there be a revolution!
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|