#P6604. [HNOI2016] 序列 加强版
[HNOI2016] 序列 加强版
Description
Given a sequence of length : , denoted as . Similarly, () refers to the sequence . If , then is called a subsequence of .
Now there are queries. Each query gives two numbers and , . For each query, find the sum of the minimum values of all distinct subsequences of . For example, given the sequence , and a query with and , then has subsequences: , , , , , . The sum of the minimum values of these subsequences is .
Input Format
The first line contains three integers , , , representing the sequence length, the number of queries, and the input method.
The second line contains integers describing the sequence.
If , then the next lines each contain two numbers and , representing the query interval .
If , then the data is generated by the following code:
namespace gen{
typedef unsigned long long ull;
ull s,a,b,c,lastans=0;
ull rand(){
return s^=(a+b*lastans)%c;
}
};
The initial values of s, a, b, c are given on the third line, where s, a, b are all in , and c is in . lastans is the value of the previous query answer converted to type unsigned long long, and for the first query it is .
For each query, you can generate and in the following way:
l=gen::rand()%n+1;
r=gen::rand()%n+1;
if(l>r) std::swap(l,r);
Output Format
Output one integer in a single line, which is the XOR sum of the answers of all queries after converting each answer to type unsigned long long.
5 5 0
5 2 4 1 3
1 5
1 3
2 4
3 5
2 5
28
6 5 1
1 1 4 5 1 4
19 19 8 10
6
Hint
- For of the data, , .
- For the other of the data, , .
Constraints: for of the data, , .
Translated by ChatGPT 5
京公网安备 11011102002149号