PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FT0000209. Kiểm tra tần suất chia hết (Kazaee)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

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 aa of nn positive integers, indexed from 11 to nn. The array changes over time; each question must be answered using the current contents.

Process qq operations in their given order. Each operation has one of two types:

  • 1 i x: Set the ii-th element to xx. Its previous value is replaced; the other positions remain unchanged.
  • 2 l r k: Consider every distinct positive integer appearing in the subarray al,al+1,…,ara_l,a_{l+1},\ldots,a_r. For such a value vv, let cvc_v be its number of occurrences in this subarray. Determine whether cvc_v is divisible by kk for every value vv 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 n,qn,q: the array length and the number of operations.
  • The second line contains exactly nn positive integers a1,a2,…,ana_1,a_2,\ldots,a_n in position order.
  • Each of the following qq lines contains one operation, either 1 i x or 2 l r k, with the parameters defined above. Positions are 11-based.

Output

For every type-2 operation, print YES if each distinct value in the selected subarray occurs a multiple of kk times; otherwise print NO. Print one answer per line in query order.

Subtasks

  • Subtask 1 (20 points): 1≤n≤401\le n\le 40; 1≤q≤401\le q\le 40; 1≤ai≤1091\le a_i\le 10^9 for every 1≤i≤n1\le i\le n; type 1 has 1≤i≤n1\le i\le n and 1≤x≤1091\le x\le 10^9; type 2 has 1≤l≤r≤n1\le l\le r\le n and 1≤k≤n1\le k\le n.
  • Subtask 2 (30 points): 1≤n≤25001\le n\le 2500; 1≤q≤25001\le q\le 2500; 1≤ai≤1091\le a_i\le 10^9 for every 1≤i≤n1\le i\le n; type 1 has 1≤i≤n1\le i\le n and 1≤x≤1091\le x\le 10^9; type 2 has 1≤l≤r≤n1\le l\le r\le n and 1≤k≤n1\le k\le n.
  • Subtask 3 (50 points): 1≤n≤3000001\le n\le 300000; 1≤q≤3000001\le q\le 300000; 1≤ai≤1091\le a_i\le 10^9 for every 1≤i≤n1\le i\le n; type 1 has 1≤i≤n1\le i\le n and 1≤x≤1091\le x\le 10^9; type 2 has 1≤l≤r≤n1\le l\le r\le n and 1≤k≤n1\le k\le n.

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 11 through 66 contain (1234,2,3,3,2,1)(1234,2,3,3,2,1). Both 12341234 and 11 occur only once, so their counts are not divisible by 22; the first answer is NO.

Next, setting a1=1a_1=1 gives the subarray (1,2,3,3,2,1)(1,2,3,3,2,1) for [1,6][1,6]. Each of 1,2,31,2,3 occurs twice, so the answer is YES. In positions [1,9][1,9], the subarray is (1,2,3,3,2,1,1,2,3)(1,2,3,3,2,1,1,2,3); each of those three values appears three times, which is not divisible by 22, so the next answer is NO.

Changing a10a_{10} to 55 does not affect positions [1,9][1,9]. With k=3k=3, all three frequencies in that subarray are divisible by 33, giving YES.

Finally, after setting a3=5a_3=5, positions [3,10][3,10] contain (5,3,2,1,1,2,3,5)(5,3,2,1,1,2,3,5). Each of 1,2,3,51,2,3,5 appears exactly twice, so the last answer is YES.