AtCoder Regular Contest 213 (Div. 1)
B
Hamming Distance is not 1
AtCoder
⌀ 2313
原题
← AC →
翻译中…

Problem Statement

翻译中…

You are given non-negative integers $q,L,R\;(q \in \{ 0,1\}, \; L \leq R)$. Consider a set $S$ that satisfies all of the following conditions.

翻译中…
  • $S$ consists of distinct integers between $L$ and $R$, inclusive.
  • If $a \in S, \; b \in S, \; a \neq b$, then $a$ and $b$ differ in at least two digits in binary representation. More formally, there exist at least two non-negative integers $i$ such that $\left\lfloor\frac{a}{2^i}\right\rfloor$ and $\left\lfloor\frac{b}{2^i}\right\rfloor$ have different parities.
  • Among those satisfying the above two conditions, the number of elements is maximum.
翻译中…

If $q=0$, find the number of elements in such a set $S$. If $q=1$, construct one such set $S$.

翻译中…

For each input file, solve $T$ test cases.

翻译中…

Constraints

翻译中…
  • $1 \leq T \leq 2 \times 10^5$
  • $0 \leq q \leq 1$
  • $0 \leq L \leq R \leq 10^{18}$
  • The sum of $q(R-L)$ over all test cases is at most $5\times 10^6$.
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

T
case_1
case_2
\vdots
case_T

翻译中…

Each case is given in the following format:

翻译中…

q L R

翻译中…

Output

翻译中…

Output the answers in a total of $T$ lines. The $t$-th line should contain the answer for the $t$-th test case. For each test case, if $q=0$, print the number of elements in a set $S$ that satisfies the conditions. If $q=1$, for a set $S$ that satisfies the conditions, let

翻译中…

$B_i=\begin{cases} 1 \; (S \text{ contains } i) \\ 0 \; (S \text{ does not contain } i) \end{cases}$

翻译中…

and output it in the following format:

翻译中…

B_LB_{L+1}\dotsB_R

翻译中…

If there are multiple sets $S$ that satisfy the conditions, you may print any of them.

翻译中…

样例

Input #1
3
1 0 3
0 1 2
1 213 213
Output #1
1001
2
1
In the first test case, $S=\{0,3\}$ satisfies the conditions. $S=\{1,2\}$ also satisfies the conditions, so it is correct as well. In the second test case, the only $S$ that satisfies the conditions is $\{1,2\}$, whose number of elements is $2$.
题目信息
题号
arc213_b
时间限制
4 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。