#K77882. Taco Query Processor

    ID: 34963 Type: Default 1000ms 256MiB

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 the i-th element of the array (1-indexed) to x.
  • Check Query (type 2): Given as 2, check if all contiguous subarrays of length K have the same sum. If they do, output 1; otherwise, output 0.

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:

  1. The first line contains three space-separated integers: N (the size of the array), K (the window size), and Q (the number of queries).
  2. The second line contains N space-separated integers representing the array A.
  3. Each of the next Q lines describes a query. A query is either in the format 1 i x (an update query) or 2 (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.

## sample
5 3 6
3 1 4 1 5
1 2 6
2
1 5 9
2
1 3 2
2
0

0 0

</p>