Agos 博士的深色模式AI (CI翻译)
Someone has chopped up Dr. Agos's chickens. Furious, he turns to the one thing that still brings him comfort: his OLED screen. Today, he wants almost all of it black.
有人把 Agos 博士的鸡剁成了碎块。他怒不可遏,转而寻求唯一还能给他带来慰藉的东西:他的 OLED 屏幕。今天,他希望屏幕几乎全黑。AI (CI翻译)
The screen has a single row of $n$ pixels. Its pattern is represented by a binary string $s$; $s_i = 0$ means that the $i$-th pixel is dark, and $s_i = 1$ means that it is lit.
屏幕只有一行,共有 $n$ 个像素。屏幕图案用一个二进制字符串 $s$ 表示;$s_i = 0$ 表示第 $i$ 个像素是暗的,$s_i = 1$ 表示它是亮的。AI (CI翻译)
Dr. Agos finds a contiguous segment of pixels irritating if, when read from left to right as a binary integer, its value is divisible by $3$. More precisely, the segment from position $l$ to position $r$ ($1 \le l \le r \le n$) has value $$ \sum_{i=l}^{r} s_i \cdot 2^{r-i}. $$ Leading zeroes are allowed. A segment consisting only of dark pixels has value $0$, which is also divisible by $3$.
如果将一段连续像素从左到右视为一个二进制整数,其值能被 $3$ 整除,Agos 博士就会觉得这段像素令人烦躁。更准确地说,从位置 $l$ 到位置 $r$($1 \le l \le r \le n$)的区间的值为 $$ \sum_{i=l}^{r} s_i \cdot 2^{r-i}. $$ 允许前导零。仅由暗像素组成的区间的值为 $0$,它也能被 $3$ 整除。AI (CI翻译)
Let $f(s)$ be the number of irritating segments. Segments with different pairs of endpoints $(l,r)$ are counted separately, even if their pixel patterns are identical.
设 $f(s)$ 为令人烦躁的区间数量。端点对 $(l,r)$ 不同的区间分别计数,即使它们的像素图案完全相同。AI (CI翻译)
Dr. Agos wants a pattern with at most three lit pixels that minimizes $f(s)$ among all binary strings of length $n$, including strings with more than three ones. Help him construct such a pattern.
Agos 博士希望构造一个至多有三个亮像素的图案,使其 $f(s)$ 在所有长度为 $n$ 的二进制字符串中达到最小值,比较范围也包括含有超过三个 $1$ 的字符串。请帮助他构造这样的图案。AI (CI翻译)
We can show that an answer always exists.
可以证明,答案总是存在。AI (CI翻译)
Input
输入格式
AI (CI翻译)Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.
每个测试包含多组测试用例。第一行包含测试用例数 $t$($1 \le t \le 10^4$)。接下来是各组测试用例的描述。AI (CI翻译)
The only line of each test case contains a single integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of pixels in the row.
每组测试用例仅包含一行,其中有一个整数 $n$($1 \le n \le 2 \cdot 10^5$)——这一行中的像素数量。AI (CI翻译)
It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.
保证所有测试用例的 $n$ 之和不超过 $2 \cdot 10^5$。AI (CI翻译)
Output
输出格式
AI (CI翻译)For each test case, print a binary string $s$ of length $n$ describing Dr. Agos's screen. It must contain at most three ones and minimize $f(s)$ among all binary strings of length $n$.
对于每组测试用例,输出一个长度为 $n$ 的二进制字符串 $s$,表示 Agos 博士的屏幕图案。它必须至多包含三个 $1$,并且其 $f(s)$ 必须在所有长度为 $n$ 的二进制字符串中达到最小值。AI (CI翻译)
If there are multiple solutions, print any of them.
如果有多个解,输出其中任意一个即可。AI (CI翻译)
Note
说明
AI (CI翻译)For $n=1$, Dr. Agos can light the only pixel, giving $s=\mathtt{1}$. The only segment has value $1$, so it is not irritating and $f(s)=0$.
当 $n=1$ 时,Agos 博士可以点亮唯一的像素,得到 $s=\mathtt{1}$。唯一的区间的值为 $1$,因此它不令人烦躁,且 $f(s)=0$。AI (CI翻译)
For $n=2$, he can light both pixels, giving $s=\mathtt{11}$. The whole row has binary value $3$ and is irritating, while each individual pixel has value $1$. Thus, $f(s)=1$. Every binary string of length $2$ has at least one irritating segment, so this is optimal.
当 $n=2$ 时,他可以点亮两个像素,得到 $s=\mathtt{11}$。整行对应的二进制数的值为 $3$,因此令人烦躁,而每个单独像素的值均为 $1$。所以,$f(s)=1$。每个长度为 $2$ 的二进制字符串都至少有一个令人烦躁的区间,因此这是最优解。AI (CI翻译)
The displayed patterns are not necessarily unique.
所展示的图案不一定是唯一的。AI (CI翻译)
样例
6
1
2
3
4
5
6
1
11
101
0101
10101
010100
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。