#P8453. 「SWTR-8」美元巨大
「SWTR-8」美元巨大
Description
Little A has powers of , . He wants to insert XOR operators and OR operators between these numbers to form an expression. It is guaranteed that .
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 , the index of the subtask.
The second line contains an integer , the number of test cases. Then follow test cases, each in the following form:
- The first line contains three integers .
- The second line contains integers , meaning .
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 .
- The second line outputs a string of length consisting of
^and|, where means the operator between and is XOR, and means the operator is OR. You must ensure that the number of^is and the number of|is .
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
0and1. - In the second line, you must not output characters other than
^and|, and the string length must be exactly . - The number of
^must be exactly , and the number of|must be exactly .
"Constraints and Conventions"
- Test point #1 (10 points): all are pairwise distinct.
- Test point #2 (20 points): all are equal.
- Test point #3 (30 points): .
- Test point #4 (25 points): .
- Test point #5 (15 points): no special restrictions.
For of the data:
- .
- .
- , .
- , i.e. .
"Help and Tips"
- About bit operations。
- Please pay attention to IO optimization.
"Source"
- Sweet Round 8 B
- Idea & Solution: Alex_Wei。
- Tester: chenxia25。
Translated by ChatGPT 5
京公网安备 11011102002149号