Sequence and Queries 37
InterviewTime limit1sMemory limit512 MB
Maintain an array under point updates, and for range queries report how many entries are even or odd.
- Level
Easy3 of 10
- Topics
- Array, Prefix sum, Segment tree, Implementation
- Solved
- No attempts yet
Problem
There is a sequence of length . Write a program that performs the following queries.
1 i x: set to .2 l r: print the number of even values among all with .3 l r: print the number of odd values among all with .
The sequence is indexed starting from 1.
Input
The first line gives the size of the sequence ().
The second line gives . ()
The third line gives the number of queries ().
Each of the next lines gives one query. (, , )
Output
Print the answers to queries of type 2 and 3, one per line.