#P95. [NOI 2025 Day 1] 序列变换
[NOI 2025 Day 1] 序列变换
Person in Charge
Problem Description
Given two integer sequences and , each of length . For a non-negative integer sequence of length , let be the set of indices where . Define and . Specifically, if is empty, then and .
Little L has a positive integer sequence of length . Little L can perform the following modifications on the sequence :
- Choose two adjacent indices in (i.e., and ). If , then set to and set to .
Little L can perform any number of such modifications or none at all. For all sequences that can be obtained from through these modifications, Little L wants to find the maximum value of and the sum of . Formally, let be the set of all sequences obtainable from through the above operations. You need to compute and . Since may be large, you only need to output its value modulo .
Scoring
For each test case:
- Correctly answering for all test data will earn of the points for that test case.
- Correctly answering modulo for all test data will earn of the points for that test case.
Attention: Even if a participant answers only one of the two questions, they must still output two integers in the specified format, corresponding to the answers for both questions.
Input Format
This problem contains multiple test cases.
The first line of input contains two non-negative integers , representing the test case number and the number of test data sets. indicates that the test case is a sample.
For each test data set:
- The first line contains a positive integer , the length of the sequence.
- The second line contains positive integers , representing sequence .
- The third line contains integers , representing sequence .
- The fourth line contains positive integers , representing sequence .
Output Format
For each test data set, output a single line containing two integers: the maximum value of and the sum of modulo . Note: does not need to be modulo .
This problem consists of two sub-questions, and correctly answering either will earn partial points. For detailed scoring rules, refer to the [Scoring] section.
Samples
0 3
3
5 6 6
3 6 9
1 2 3
6
1 1 4 5 1 4
-1 1 -1 1 -2 2
1 1 1 1 1 1
8
4 2 4 2 2 2 4 4
-2 4 9 -3 4 8 7 8
1 1 1 1 1 1 1 1
15 10
1 18
37 48
Sample 1 Explanation
This sample contains three test data sets.
For the first test data set, the following 4 sequences can be obtained:
- , , ;
- , , ;
- , , ;
- , , .
Thus, , and .
Sample 2
See the files sequence/sequence2.in and sequence/sequence2.ans in the contestant directory.
This sample satisfies the constraints of test cases and .
Sample 3
See the files sequence/sequence3.in and sequence/sequence3.ans in the contestant directory.
This sample satisfies the constraints of test cases and .
Sample 4
See the files sequence/sequence4.in and sequence/sequence4.ans in the contestant directory.
This sample satisfies the constraints of test case .
Sample 5
See the files sequence/sequence5.in and sequence/sequence5.ans in the contestant directory.
This sample satisfies the constraints of test cases and .
Sample 6
See the files sequence/sequence6.in and sequence/sequence6.ans in the contestant directory.
This sample satisfies the constraints of test cases .
Data Range
Let be the sum of across all test data sets in a single test case. For all test data, the following guarantees hold:
- ;
- , ;
- For all , ;
- For all , ;
- For all , .
| Test Case | Special Properties | ||
|---|---|---|---|
| None | |||
| B | |||
| None | |||
| A | |||
| B | |||
| None | |||
| A | |||
| B | |||
| None | |||
- Special Property A: .
- Special Property B: For all , is generated independently and uniformly at random from .