#P4497. [WC2011] 拼点游戏
[WC2011] 拼点游戏
Description
Xiao W and Xiao Y both enjoy a “point-picking game.” In the game, each of the two players produces a number as their “score” through some operation, and the player with the larger score wins. The rules of the “point-picking game” are as follows:
- At the start of the game, you are given a positive integer sequence with elements, .
- An index sequence of is an integer sequence satisfying (where can be , i.e., the sequence can be empty), and its corresponding subsequence of is .
- The score corresponding to the index sequence is defined as .
- During the game, the two players each choose an index sequence, and the one whose chosen index sequence corresponds to a larger score wins.
However, in every game, Xiao W can always compute, accurately and flawlessly, the optimal index sequence that maximizes the score. To make the game more competitive, they added the following extra rules:
Ex1. Xiao W may choose a non-empty interval and increase by an integer simultaneously; the new sequence replaces the original sequence .
Ex2. When they play a “point-picking game” on the current sequence , Xiao Y is allowed, after Xiao W has chosen the optimal index sequence , to modify any number of times. Each modification follows the rules below: (1) Arbitrarily choose a positive integer satisfying , and two non-negative integers satisfying ; (2) Change to , and change to .
If, after some number of modifications by Xiao Y to the index sequence chosen by Xiao W, the corresponding score is less than or equal to , then Xiao Y wins.
Now, given the information about Xiao W’s Ex1 operations, for each “point-picking game,” please help them compute: a) What is the score of the optimal index sequence that Xiao W can initially choose? b) What is the minimum number of modification operations Xiao Y needs in order to win, i.e., to make ?
Input Format
The first line of the input file joy.in contains a positive integer , the number of groups of testdata. Then follow groups of data.
For each group of data, the first line contains two integers and , denoting the number of elements in and the number of events, respectively.
The next line contains positive integers separated by single spaces, where the -th integer is the -th element in the initial sequence.
The following lines each describe an event (given in chronological order). The first number in each line is either or , indicating the type of the event.
If it is : after the there are three integers , , and (all separated by single spaces), meaning Xiao W increases by .
If it is : the two players play a “point-picking game,” and you need to output the corresponding result.
The input guarantees that all elements in the sequence are always positive integers.
Output Format
The output file is joy.out. For each group of testdata, for each “point-picking game” in order, output one line containing two integers separated by a single space, and , where
- is the score of the optimal index sequence that Xiao W can choose for the current sequence ;
- is the minimum number of modification operations that Xiao Y needs to win. If Xiao Y cannot win no matter how many operations are performed, output
-1.
The data guarantee that the optimal index sequence is always unique.
2
5 9
9 10 7 6 8
1
0 4 5 2
0 3 5 4
1
0 2 5 -2
0 3 5 -3
0 4 5 -2
0 5 5 -4
1
4 3
2 4 3 5
1
0 3 3 3
1
3 1
5 -1
0 0
4 -1
4 -1
Hint
Scoring rules:
- A test point contains multiple groups of testdata. For that test point:
- If all are correct but some is incorrect, you get 3 points.
- If all are correct but some is incorrect, you get 7 points.
- If all answers are correct, you get 10 points.
Sample explanation:
- The input contains two groups of testdata.
- In the first group: In the first “point-picking game,” the optimal index sequence is . Xiao Y needs only one modification: choose and non-negative integers , . After the modification, the index sequence becomes , and Xiao Y wins.
- In the third “point-picking game,” the sequence is . Xiao W chooses the empty sequence as the optimal index sequence, yielding a score of . In this case, Xiao Y cannot make any modification (nor is any modification needed), and Xiao Y already wins.
Constraints:
- For 10% of the data, .
- For 30% of the data, .
- For another 20% of the data, and .
- For 100% of the data, and , and the initial sequence satisfies and .
Translated by ChatGPT 5
京公网安备 11011102002149号