#P7432. [THUPC 2017] 钦妹的玩具商店
[THUPC 2017] 钦妹的玩具商店
Problem Description
Qin Mei and Frez have a toy shop in City C. The shop sells kinds of toys, numbered . The unit price of the -th toy is yuan, and buying one such toy provides happiness .
One day, children came to City C. According to reliable information, during the next days, these children will come to the shop every day to buy things. The -th child brings yuan every day ().
Since some toys are not very good, each day different toys will be banned from being sold to children. Specifically, on day , toys with indices in the interval cannot be bought by children.
In addition, to prevent the children from being too happy, each toy has a purchase limit . That is, for the -th kind of toy, each child can buy a non-negative integer number of items per day, and this number must not exceed .
Now, for each day, you want to know:
- The sum of the maximum happiness that all children can obtain (modulo ).
- The xor of the maximum happiness that all children can obtain (the xor operation is , i.e. the
^operator in C++/Java/Python).
This problem is forced online, and the specific rules are reflected in the input description.
Input Format
Read from standard input.
The input contains multiple test cases. The first line contains an integer , the number of test cases. For each test case:
The first line contains three integers , representing the number of toys, the number of children, and the number of days.
The second line contains non-negative integers, describing the unit prices .
The third line contains non-negative integers, describing the happiness values .
The fourth line contains non-negative integers, describing the purchase limits .
Lines to each contain two integers describing an interval. The -th line and the previous day's answer together determine the forbidden index interval on day . Suppose the previous day's sum of maximum happiness is . Then satisfy:
$$l_i=\min((x+\operatorname{lastans}-1)\bmod n+1,(y+\operatorname{lastans}-1)\bmod n+1)$$$$r_i=\max((x+\operatorname{lastans}-1)\bmod n+1,(y+\operatorname{lastans}-1)\bmod n+1)$$On the first day, we define . It is guaranteed that .
Output Format
Write to standard output.
For each test case, output lines. Each line contains two integers, in order:
- The sum of the maximum happiness that all children can obtain (modulo ).
- The xor of the maximum happiness that all children can obtain.
2
3 10 3
2 3 3
20 50 24
3 1 10
1 1
2 2
3 3
2 7 3
6 7
1 2
1 1
1 1
2 2
1 2
568 120
660 20
660 20
2 2
2 0
0 0
Hint
Constraints: For all testdata, , , .
Copyright Information
From THUPC (THU Programming Contest, Tsinghua University Programming Contest) 2017.
Translated by ChatGPT 5