#P11269. 【MX-S5-T3】IMAWANOKIWA (Construction ver.)
【MX-S5-T3】IMAWANOKIWA (Construction ver.)
Background
Original problem link: https://oier.team/problems/S5C。
IMAWANOKIWA - Iyowa / Hatsune Miku
あなたの未来が見たかった。
Problem Description
You are given a sequence of initial length that contains only . You can perform the following operation:
- Choose two adjacent positions and , delete , and insert at the original position. The second half of the sequence therefore shifts forward by one position. Here, denotes the number of 's in the binary representation of .
Obviously, after each operation the sequence length decreases by , so after performing operations, the sequence will end up with exactly one number.
Let the minimum possible remaining number after all possible sequences of operations be . Define a good operation sequence as a positive integer sequence of length , where denotes the chosen in the -th operation (clearly ), and after performing operations according to this sequence, the remaining number equals . You need to output and the lexicographically smallest good operation sequence.
If you cannot find the lexicographically smallest good operation sequence, you can still get partial points, see [Scoring] for details.
To avoid excessive output, you only need to output the hash value of the lexicographically smallest good operation sequence under a certain hashing method, see [Output Format] for details.
Input Format
This problem contains multiple test cases.
The first line contains a positive integer , the number of test cases. Then for each test case:
- A single line containing a string of length , where the -th character represents .
Output Format
For each test case:
- Output one line with two non-negative integers , where
- The first number is the minimum possible remaining number.
- The second number is the hash value of the lexicographically smallest good operation sequence , defined below.
- Even if the second number you output is incorrect, you can still get partial points, and the problem will use a custom checker to do this. See [Scoring] for details.
Let and . We define the hash value of a positive integer sequence as modulo .
Hint: In code, you can use the natural overflow of C++ type
unsigned long longto achieve the modulo effect.
7
110121
120202
1202
1121212
000
010101110
0112210112
1 31589928355420248
1 31587559229276557
2 177728893
2 15233797274127957404
0 13332
1 4098728445451629840
1 892964726593242284
Hint
[Sample Explanation #1]
For the first test case, the lexicographically smallest good operation sequence is . When performing operations according to this sequence, the changes of sequence are as follows:
$$[1, 1, 0, 1, 2, 1]\\ [1, 0, 1, 2, 1]\\ [1, 0, 2, 1]\\ [1, 1, 1]\\ [1, 1]\\ [1]$$So the hash value you should output is $\mathrm{Hash}([1, 3, 2, 1, 1]) = (1 \times 13331^4 + 3 \times 13331^3 + 2 \times 13331^2 + 1 \times 13331^1 + 1 \times 13331^0) \bmod 2^{64} = 31589928355420248$.
For the second test case, the lexicographically smallest good operation sequence is . When performing operations according to this sequence, the changes of sequence are as follows:
$$[1, 2, 0, 2, 0, 2]\\ [2, 0, 2, 0, 2]\\ [2, 1, 0, 2]\\ [2, 1, 2]\\ [2, 2]\\ [1]$$[Sample #2]
See popc/popc2.in and popc/popc2.ans in the attachments.
This sample contains ten test cases. All test cases satisfy . Among them, test cases satisfy that there is no in sequence , and test cases satisfy that there is no in sequence .
[Sample #3]
See popc/popc3.in and popc/popc3.ans in the attachments.
This sample contains forty test cases. Among them, test cases satisfy , satisfy , satisfy , and satisfy .
[Scoring]
This problem will use a custom checker to compute your partial score.
For a test point, if there exists any testdata where the minimum value you output is incorrect, then you cannot get any score for this test point.
For a test point, if the minimum value you output is correct for every test case, but there exists some testdata where the hash value of the lexicographically smallest good operation sequence you computed is incorrect, then you can get of the score for this test point (i.e. point, see [Constraints]). Note that you still need to output any integer within as the hash value of your solution.
For a test point, if the minimum value you output is correct for every test case, and the hash value of the lexicographically smallest good operation sequence you computed is also correct, then you can get the full score for this test point.
[Constraints]
For all testdata, it is guaranteed that , , and sequence contains only .
| Test Point ID | Special Property | ||
|---|---|---|---|
| None | |||
| No in sequence | |||
| No in sequence | |||
| None | |||
Translated by ChatGPT 5