#FT0000209. Kiểm tra tần suất chia hết (Kazaee)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Kiểm tra tần suất chia hết (Kazaee)
Kazaee
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an array of positive integers, indexed from to . The array changes over time; each question must be answered using the current contents.
Process operations in their given order. Each operation has one of two types:
1 i x: Set the -th element to . Its previous value is replaced; the other positions remain unchanged.2 l r k: Consider every distinct positive integer appearing in the subarray . For such a value , let be its number of occurrences in this subarray. Determine whether is divisible by for every value occurring there.
Values absent from the chosen subarray do not affect the result. Answer all type-2 queries in order, applying every preceding assignment first.
Input
- The first line contains : the array length and the number of operations.
- The second line contains exactly positive integers in position order.
- Each of the following lines contains one operation, either
1 i xor2 l r k, with the parameters defined above. Positions are -based.
Output
For every type-2 operation, print YES if each distinct value in the selected subarray occurs a multiple of times; otherwise print NO. Print one answer per line in query order.
Subtasks
- Subtask 1 (20 points): ; ; for every ; type
1has and ; type2has and . - Subtask 2 (30 points): ; ; for every ; type
1has and ; type2has and . - Subtask 3 (50 points): ; ; for every ; type
1has and ; type2has and .
Examples
Input
10 8
1234 2 3 3 2 1 1 2 3 4
2 1 6 2
1 1 1
2 1 6 2
2 1 9 2
1 10 5
2 1 9 3
1 3 5
2 3 10 2
Output
NO
YES
NO
YES
YES
Explanation
Initially, positions through contain . Both and occur only once, so their counts are not divisible by ; the first answer is NO.
Next, setting gives the subarray for . Each of occurs twice, so the answer is YES. In positions , the subarray is ; each of those three values appears three times, which is not divisible by , so the next answer is NO.
Changing to does not affect positions . With , all three frequencies in that subarray are divisible by , giving YES.
Finally, after setting , positions contain . Each of appears exactly twice, so the last answer is YES.