#P6638. 「JYLOI Round 1」常规
「JYLOI Round 1」常规
Description
LS has made routines, where the time when the -th routine was created is .
For the -th routine, every seconds after its creation time , he has to do the -th routine once. The time it takes to do a routine can be ignored.
Now LS wants to ask you queries. Each query is given as an interval , asking how many times in total he did all routines from second to second .
Input Format
The first line contains an integer , which is either or , and it will be used below.
For , the next line contains three positive integers , , and , with meanings as described above.
The next line contains positive integers. The -th positive integer in this line is , with meaning as described above.
Then there are lines. The -th line indicates that the -th query is an interval , where and have meanings as described above. For all queries with , we do not apply any encryption.
For , the next line contains four positive integers , , , and . The meanings of , , and are as described above, and is a parameter used below.
The next line contains positive integers. The -th positive integer in this line is , with meaning as described above.
Then there are lines. The -th of these lines contains two positive integers and , indicating that the -th query is an interval , where and have meanings as described above. In particular, we encrypt queries to . For the -th query , after decryption:
$$l_i = \min((l_i + \text{lastans} - 1) \;\text{mod}\; mod + 1, (r_i + \text{lastans} - 1) \;\text{mod}\; mod + 1)$$$$r_i=\max((l_i + \text{lastans} - 1) \;\text{mod}\; mod + 1, (r_i + \text{lastans} - 1) \;\text{mod}\; mod + 1)$$Here is the answer to the -th query. For queries to , your program needs to output the answer for the decrypted query.
In particular, the first query is not encrypted.
Output Format
Output lines in total. For each decrypted query, output one line. The -th output line is the answer to the -th query.
0
5 10 3
1 2 3 4 5
1 5
2 5
3 5
4 5
5 5
10 10
20 30
10 30
1 30
5 30
2
2
2
2
1
2
18
35
43
42
1
5 10 3 100
1 2 3 4 5
1 5
2 5
3 5
4 5
5 5
10 10
20 30
10 30
1 30
5 30
2
5
5
3
2
1
18
35
50
44
Hint
Explanation of Sample 2
The decrypted queries are [1, 5], [4, 7], [8, 10], [9, 10], [8, 8], [12, 12], [21, 31], [28, 48], [36, 65], [55, 80], so the answers can be obtained.
Constraints
For of the data, $type \in \{0, 1\}; 1 \leq n, m \leq 10^5; 0 \leq l_i \leq r_i \leq 10^9; 0 \leq a_i \leq 10^9; 1 \leq k, mod \leq 10^9$.
Subtask 1 (10 test points, 1 point each, 10 points total): .
Subtask 2 (10 test points, 1 point each, 10 points total): .
Subtask 3 (2 test points, 5 points each, 10 points total): .
Subtask 4 (20 points total): .
Subtask 5 (30 points total): .
Subtask 6 (20 points total): no special constraints.
For Subtasks 4, 5, and 6, scoring is bundled (that is, you must pass all test points within a subtask to get the points for that subtask). This problem has 50 test points in total, worth 100 points.
Problem Source
"JYLOI Round 1" D.
Idea / Solution / Data: abcdeffa.
Translated by ChatGPT 5
京公网安备 11011102002149号