Loading...
Range Equal Query
Time: 1 s
Memory: 125 MB
This is another simple range query problem where you will perform some updates and answer some queries. Let's take an array \(A\) of length \(N\) and an array \(B\) of length \(M\).

You will have to perform \(Q\) operations on this array. There will be two types of operations:
 
  • 1 X V - Change the value of \(X^{th}\) index of array \(A\) to \(V\)
  • 2 L R - Pick the subarray array from \(A\) which range \(L\) to \(R\) formally make the subarray \(A[L]\) to \(A[R]\) and check this subarray is equal to array \(B\) or not. Its guaranteed that \(R-L+1 = M\).
All indexes are 1-based.

Two array is equal if below this condition fill,
     \(A[L] = B[1], A[L+1] = B[2],......, A[R-1] = B[M-1], A[R] = B[M]\)  
Input
The first line contains two integers  \(N (1 \leq N \leq 10^5)\) and  \(M(1 \leq M \leq 10^4)\)  the size of the array \(A\) and size of array \(B\).
The next line contains \(N\) numbers \(A_i\), the initial state of the array \(A(1\leq A_i\leq10^6)\).
The next line contains M numbers \(B_i\), the initial state of the array \(B(1\leq B_i\leq10^6)\).
The next line contain an integer query \(Q (1 \leq Q\leq 10^5)\).
Then each of the next \(Q \) lines contains a task in one of the following form:
    1 X V (\(1 \leq X \leq N, 1 \leq V \leq 10^6\))
    2 L R (\(1 \leq L \leq R \leq N, R-L+1 = M\))
Output
For each query 2 L R, if subarray of A[L] to A[R] is equal to \(B\) then print YES otherwise print NO.
Examples
Input
Output
5 3
1 2 3 2 3
1 2 3
5
2 1 3
2 3 5
1 3 1
2 3 5
2 1 3
YES
NO
YES
NO
Input
Output
5 2
1 4 1 5 3
3 1
5
1 4 3
1 5 1
2 4 5
2 3 4
1 4 836991
YES
NO
Input
Output
5 2
5 2 4 17 16
12 2
5
1 4 12
1 5 2
2 4 5
2 1 2
1 4 286918
YES
NO
Problem Info
Problem ID 59
Time Limit 1000 ms
Memory Limit 128000 KB
Moderators AmirHamza
Statistics
Submit
You need to Login or Registration for submit your solution