#K46432. Process Logs Query
Process Logs Query
Process Logs Query
You are given a sequence of integers and a list of operations to perform on this sequence. There are two types of operations:
- Q p v: Query the sequence at the 1-indexed position p. If the value at that position is equal to v, print
YES
; otherwise printNO
. - U p v: Update the sequence at the 1-indexed position p with the new value v.
Your task is to process all operations in the order they are given and for each query operation, output the appropriate response.
Note: The positions are 1-indexed.
inputFormat
The input is read from stdin and contains the following:
- An integer N denoting the number of elements in the sequence.
- A line with N space-separated integers representing the initial sequence.
- An integer M denoting the number of operations.
- M lines each containing an operation in one of the following formats:
Q p v
— to query whether the element at position p equals v.U p v
— to update the element at position p to v.
outputFormat
For each query operation (Q
), print a single line containing either YES
or NO
to stdout.
5
3 8 12 6 7
4
Q 2 8
Q 4 10
U 4 10
Q 4 10
YES
NO
YES
</p>