CF BUDDY
← Problems·

1264B · Beautiful Sequence

1900 · brute force, constructive algorithms, greedy

Problem: An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to 11. More formally, a sequence s1,s2,,sns_1, s_2, \ldots, s_{n} is beautiful if sisi+1=1|s_i - s_{i+1}| = 1 for all 1in11 \leq i \leq n - 1.

Trans has aa numbers 00, bb numbers 11, cc numbers 22 and dd numbers 33. He wants to construct a beautiful sequence using all of these a+b+c+da + b + c + d numbers.

However, it turns out to be a non-trivial task, and Trans was not able to do it. Could you please help Trans?

Input Format: The only input line contains four non-negative integers aa, bb, cc and dd (0<a+b+c+d1050 < a+b+c+d \leq 10^5).

Output Format: If it is impossible to construct a beautiful sequence satisfying the above constraints, print "NO" (without quotes) in one line.

Otherwise, print "YES" (without quotes) in the first line. Then in the second line print a+b+c+da + b + c + d integers, separated by spaces — a beautiful sequence. There should be aa numbers equal to 00, bb numbers equal to 11, cc numbers equal to 22 and dd numbers equal to 33.

If there are multiple answers, you can print any of them.

Note: In the first test, it is easy to see, that the sequence is beautiful because the difference between any two consecutive numbers is equal to 11. Also, there are exactly two numbers, equal to 00, 11, 22 and exactly one number, equal to 33.

It can be proved, that it is impossible to construct beautiful sequences in the second and third tests.

Sample Cases

Case 1

Input

2 2 2 1

Output

YES
0 1 0 1 2 3 2

Case 2

Input

1 2 3 4

Output

NO

Case 3

Input

2 2 2 3

Output

NO

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback