#P8553. 醒来

    ID: 9805 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>递归洛谷原创Special JudgeO2优化分治构造洛谷月赛

醒来

Background

“Where did the fireworks we once envied go? The friends we trusted have drifted away.

What did I insist on when I was young? Do you still remember?”

Thinking back to what we looked like as children, we are already very different from who we are now; but thinking about ourselves yesterday, there seems to be little difference from today. These unintentional changes have made us into someone else.

Problem Description

Herta uses a sequence aa of length rl+1r-l+1 to describe how her personality has changed. But Herta has a poor memory: she can no longer remember aa, and only remembers two non-negative integers l,rl, r, where l<rl<r.

However, she still remembers that:

  1. lairl\le a_i\le r, and all aia_i are distinct. In other words, aa is a permutation of lrl\sim r.
  2. For all 1irl1\le i\le r-l, $\operatorname{popcount}(a_i \mathbin{\mathrm{xor}} a_{i+1})=1$. In other words, two adjacent numbers in aa differ by exactly one bit in binary.

Please tell her one possible aa, or tell her that such an aa does not exist.

Input Format

A single line with two non-negative integers l,rl, r.

Output Format

On the first line, output Yes if there is a solution, otherwise output No. Case does not matter.

If you output Yes, you may output your construction in one of the following two formats:

  1. Output one line with rl+1r-l+1 numbers, representing the permutation you constructed.
  2. First output one number, representing the first number of your permutation. Then output a string of length rlr-l. For the ii-th character, if the ii-th and (i+1)(i+1)-th numbers in your permutation differ by 2k2^k, you should output the (k+1)(k+1)-th lowercase English letter, i.e. (char)('a'+k).

Note: If you use Format 1, you may not be able to pass the last two subtasks. If you receive the judging result from UKE, please consider changing the output format of your answer.


[Scoring Method]

This problem uses a custom checker to validate your output.

If your judgment about whether a solution exists is wrong, you will get no points.

If your judgment about existence is correct, you can get 40%40\% of the points; if no solution exists or you provide a correct construction, you can get the remaining 60%60\% of the points.

0 7

Yes
0 1 3 2 6 7 5 4

0 7

yEs
0 abacaba

0 7

yes

3 5

No

Hint

[Sample Explanation #1, #2, #3]

Sample outputs #1 and #2 correspond to the same sequence, i.e. {0,1,3,2,6,7,5,4}\{ 0, 1, 3, 2, 6, 7, 5, 4 \}. Both can get 100%100 \% of the score for that test point.

Sample output #3 can get 40%40 \% of the score for that test point.


[Constraints]

For all testdata, it is guaranteed that 0l<r1070\le l<r\le 10^7.

Let n=rl+1n=r-l+1.

Subtask ID n n \leq Special Constraints Points
11 10 10 9 9
22 20 20
33 105 10^5 A, B\textsf{A, B} 10 10
44 A\textsf{A}
55 2000 2000 C\textsf{C} 25 25
66 5×105 5 \times 10^5 D\textsf{D} 20 20
77 3×106 3 \times 10^6 10 10
88 7 7

A\textsf A: Guaranteed that l=0l=0.

B\textsf B: Guaranteed that nn is an integer power of 22.

C\textsf C: Guaranteed that ll is even and rr is odd.

D\textsf D: This subtask has 5 test points, generated randomly from all solvable cases with n2×105n\ge 2\times 10^5.


Even if she keeps changing, Herta may still be the same as she was in childhood.

Translated by ChatGPT 5