시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 18 | 0 | 0 | 0.000% |
Majorant of a multiset is an element which occurs more frequently than all other elements combined. Some multisets do not have majorant.
Given is an array containing n positive integers a[1], a[2], ..., a[n]. A subarray of array a is the sequence a[l], a[l+1] … a[r], where 1 ≤ l ≤ r ≤ n.
We consider m queries of two types:
First line of the standard input contains the number n. The second line of the standard input contains n integers – the element of the given array. The third line of the standard input contains the number m. From each of the next m lines read 3 numbers: l, r and t - the query in an encrypted form.
To decrypt the query: Let last_output be the last number on the standard output produced by your program (or 0, if there are no such)
Compute type=((t+last_output) mod 2) +1
If type=1 the query is "Update" with p=((l+last_output) mod n)+1, q=((r+last_output) mod 100 000 000)+1
If type=2, the query is "Query" with p=((l+last_output) mod n)+1, q=((r+last_output) mod n)+1
For every query of type 2, output on a separate line the answer to the query.
번호 | 배점 | 제한 |
---|---|---|
1 | 10 | n ≤ 100, m ≤ 50 |
2 | 15 | n ≤ 1 000, m ≤ 50 |
3 | 10 | n ≤ 10 000, m ≤ 50 |
4 | 10 | n ≤ 50 000, m ≤ 5 |
5 | 20 | n ≤ 65 000, m ≤ 50 |
6 | 35 | There are no additional constraints. |
4 1 2 2 1 3 4 3 1 2 99999990 2 4 2 1
12 6
After decrypting, the first query becomes “query, p=1, q=4”. There are 2 subarrays with majorant 1 and 5 with majorant 2 so the answer is 2*1+5*2=12.
The second query becomes “update, p=3, q=3”. After that, the array becomes: 1, 2, 3, 1.
The third query is: “query, p=1, q=3”. There is 1 subarray with majorant 1, 1 with majorant 2 and 1 with majorant 3.