#K77882. Taco Query Processor
Taco Query Processor
Taco Query Processor
You are given an array A of N integers and an integer K representing a window size. You need to process Q queries on the array. The queries are of two types:
- Update Query (type 1): Given in the form
1 i x
, update thei
-th element of the array (1-indexed) tox
. - Check Query (type 2): Given as
2
, check if all contiguous subarrays of length K have the same sum. If they do, output1
; otherwise, output0
.
If K is greater than N, then the array is trivially considered well-ordered and the answer is 1
for a check query.
Your task is to implement a program that processes these queries in the order they are given and prints the answer for every check query on standard output.
inputFormat
The input is given via standard input and has the following format:
- The first line contains three space-separated integers:
N
(the size of the array),K
(the window size), andQ
(the number of queries). - The second line contains
N
space-separated integers representing the arrayA
. - Each of the next
Q
lines describes a query. A query is either in the format1 i x
(an update query) or2
(a check query).
outputFormat
For each check query (type 2), output a single line containing either 1
if all contiguous subarrays of length K have the same sum, or 0
otherwise.
5 3 6
3 1 4 1 5
1 2 6
2
1 5 9
2
1 3 2
2
0
0
0
</p>