#P8453. 「SWTR-8」美元巨大

    ID: 7516 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>贪心洛谷原创Special JudgeO2优化位运算,按位构造洛谷月赛

「SWTR-8」美元巨大

Description

Little A has nn powers of 22, a1,a2,,ana_1, a_2, \cdots, a_n. He wants to insert xx XOR operators and yy OR operators between these numbers to form an expression. It is guaranteed that x+y=n1x + y = n - 1.

The larger the expression is, the more likely it can blow up Little T's blog. Little A wants the value of the expression to be as large as possible when it is evaluated from left to right. He wants to know the maximum possible value of the expression, written in binary. He also wants you to construct such an expression, because he is too lazy to do it himself.

If there are multiple valid constructions, output any one.

There are multiple test cases.

Input Format

The first line contains an integer SS, the index of the subtask.

The second line contains an integer TT, the number of test cases. Then follow TT test cases, each in the following form:

  • The first line contains three integers n,x,yn, x, y.
  • The second line contains nn integers bib_i, meaning ai=2bia_i = 2 ^ {b_i}.

Output Format

For each test case:

  • The first line outputs a binary number representing the answer. Leading zeros are not allowed, unless the answer is 00.
  • The second line outputs a string of length n1n - 1 consisting of ^ and |, where si=ˆs_i = \texttt{\,\,\^{}\,\,} means the operator between aia_i and ai+1a_{i + 1} is XOR, and si=|s_i = \texttt | means the operator is OR. You must ensure that the number of ^ is xx and the number of | is yy.
0
4
4 0 3
1 0 6 4
8 5 2
1 5 5 7 1 5 5 7
1 0 0
15
4 3 0
65535 65535 57 57

1010011
|||
10100000
^|^^^^|
1000000000000000

0
^^^

Hint

"Scoring"

For each test case:

  • If the first line you output is worse than the standard answer, you get 0 points.
  • If the first line you output is better than the standard answer, then the checker will verify whether your construction is correct. If it is correct, it returns _fail, which appears as UKE for the test point; otherwise you get 0 points.
  • Otherwise, your first line is the same as the standard answer. If your construction is incorrect, you get 0.6 points; otherwise you get 1 point.

The score of each test point is the minimum score among all test cases in that test point multiplied by the value of that test point.

Note that the checker can detect that your answer is better than the standard answer only if your output strictly matches the format. Once the output format is incorrect, you get 0 points. Format restrictions include but are not limited to:

  • In the first line, you must not output characters other than 0 and 1.
  • In the second line, you must not output characters other than ^ and |, and the string length must be exactly n1n - 1.
  • The number of ^ must be exactly xx, and the number of | must be exactly yy.

"Constraints and Conventions"

  • Test point #1 (10 points): all bib_i are pairwise distinct.
  • Test point #2 (20 points): all bib_i are equal.
  • Test point #3 (30 points): n8n \leq 8.
  • Test point #4 (25 points): n103n \leq 10 ^ 3.
  • Test point #5 (15 points): no special restrictions.

For 100%100\% of the data:

  • 1T201\leq T\leq 20.
  • 1n2.5×1041 \leq n \leq 2.5 \times 10 ^ 4.
  • 0x,y<n0 \leq x, y < n, x+y=n1x + y = n - 1.
  • 1ai<222221\leq a_i < 2 ^ {2 ^ {2 ^ {2 ^ 2}}}, i.e. 0bi<655360\leq b_i < 65536.

"Help and Tips"

"Source"

Translated by ChatGPT 5