你删我删AI (CI翻译)
Alice and Bob are given a binary string$^{\text{∗}}$ $s$ of length $n$. It contains at least one $\mathtt{0}$ and at least one $\mathtt{1}$.
Alice 和 Bob 得到一个长度为 $n$ 的二进制串$^{\text{∗}}$ $s$。其中至少包含一个 $\mathtt{0}$ 和一个 $\mathtt{1}$。AI (CI翻译)
They each perform exactly one operation in the following order:
他们按以下顺序各进行一次操作:AI (CI翻译)
- First, Alice chooses an occurrence of
$\mathtt{0}$in$s$and deletes it. - Then, Bob chooses an occurrence of
$\mathtt{1}$in the resulting string and deletes it.
- 首先,Alice 选择
$s$中一个$\mathtt{0}$的出现位置并将其删除。 - 然后,Bob 选择所得字符串中一个
$\mathtt{1}$的出现位置并将其删除。
Alice wants the final string to be lexicographically$^{\text{†}}$ as large as possible, while Bob wants it to be lexicographically as small as possible. Determine the final string if both players act optimally.
Alice 希望最终字符串的字典序$^{\text{†}}$尽可能大,而 Bob 希望最终字符串的字典序尽可能小。假设双方都采取最优策略,求最终字符串。AI (CI翻译)
$^{\text{∗}}$A binary string is a string consisting only of the characters $\mathtt{0}$ and $\mathtt{1}$.$^{\text{†}}$For two distinct binary strings $a$ and $b$ of the same length, $a$ is lexicographically smaller than $b$ if, at the first position where they differ, $a$ has the smaller digit.
$^{\text{∗}}$二进制串是仅由字符 $\mathtt{0}$ 和 $\mathtt{1}$ 组成的字符串。$^{\text{†}}$对于两个不同且长度相同的二进制串 $a$ 和 $b$,如果在它们首次出现不同字符的位置上,$a$ 的数字小于 $b$ 的数字,则称 $a$ 的字典序小于 $b$。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 100$). The description of the test cases follows.
每个测试包含多个测试用例。第一行包含测试用例数量 $t$($1 \le t \le 100$)。接下来是各测试用例的描述。AI (CI翻译)
The only line of each test case contains a binary string $s$ of length $n$ ($3 \le n \le 100$).
每个测试用例仅有一行,包含一个长度为 $n$ 的二进制串 $s$($3 \le n \le 100$)。AI (CI翻译)
It is guaranteed that $s$ contains at least one $\mathtt{0}$ and at least one $\mathtt{1}$.
保证 $s$ 中至少包含一个 $\mathtt{0}$ 和一个 $\mathtt{1}$。AI (CI翻译)
Output
输出格式
AI (CI翻译)For each test case, output the final string if both players act optimally.
对于每个测试用例,输出双方都采取最优策略时的最终字符串。AI (CI翻译)
Note
说明
AI (CI翻译)In the first test case, Alice must delete the only $\mathtt{0}$. Bob may delete either occurrence of $\mathtt{1}$, so the resulting string is $\mathtt{1}$.
在第一个测试用例中,Alice 必须删除唯一的 $\mathtt{0}$。Bob 可以删除任意一个 $\mathtt{1}$,因此最终字符串为 $\mathtt{1}$。AI (CI翻译)
In the second test case, Alice may delete either occurrence of $\mathtt{0}$. Bob optimally deletes one of the first two occurrences of $\mathtt{1}$, so the resulting string is $\mathtt{101}$.
在第二个测试用例中,Alice 可以删除任意一个 $\mathtt{0}$。Bob 会采取最优策略,删除前两个 $\mathtt{1}$ 中的一个,因此最终字符串为 $\mathtt{101}$。AI (CI翻译)
In the third test case, Alice may delete any occurrence of $\mathtt{0}$. Bob then deletes the only occurrence of $\mathtt{1}$, so the resulting string is $\mathtt{00}$.
在第三个测试用例中,Alice 可以删除任意一个 $\mathtt{0}$。随后 Bob 删除唯一的 $\mathtt{1}$,因此最终字符串为 $\mathtt{00}$。AI (CI翻译)
样例
4
101
11001
0010
0101010000010100100101
1
101
00
01010000010100100101
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。