#P9055. [集训队互测 2021] 数列重排
[集训队互测 2021] 数列重排
Background
dottle bot。
Problem Description
Define the of an interval of a sequence as the smallest natural number that does not appear in the interval. Define the value of a sequence as the number of intervals whose .
Given natural numbers less than and an interval , let denote, among all permutations of the sequence formed by these numbers, the maximum possible value of the sequence. For each , find .
Let denote the number of occurrences of number . It is guaranteed that there exists a positive integer such that .
Input Format
Since may be very large, the following method is used to reduce input size:
The first line contains four integers .
The second line contains a binary string of length . If the -th position is , then the number of occurrences of is ; otherwise, the number of occurrences is .
From the input, we can derive , where is the number of 's in the binary string.
Output Format
To reduce output size, let $ans=\displaystyle{\bigoplus_{i=l}^r} (233^if(i)\bmod 998244353)$, where denotes bitwise XOR in binary. Output one line containing the integer .
2 0 1 2
10
3034
14 1 14 13
10110101110101
379883349
Hint
Explanation for Sample 1
In the sample sequence, there are zeros and ones. For any permutation, is always . When the permutation is , reaches its maximum value . The answer is:
$$\displaystyle (233^0\times 15\bmod 998244353)\oplus(233^1\times 13\bmod 998244353)=3034$$Constraints
- Subtask 1 (5 points): .
- Subtask 2 (15 points): .
- Subtask 3 (15 points): .
- Subtask 4 (5 points): ,,。
- Subtask 5 (10 points): ,,。
- Subtask 6 (10 points): ,,。
- Subtask 7 (15 points): ,。
- Subtask 8 (15 points): 。
- Subtask 9 (10 points): No special constraints.
For all testdata, it holds that , , , .
Translated by ChatGPT 5