Quadrat Survey (Easy)
InterviewTime limit1sMemory limit1024 MB
Given N flower kinds in a row, answer how many flowers of a given kind lie in a range, and remove all flowers in a range on request.
- Level
Easy3 of 10
- Topics
- Array, Simulation
- Solved
- No attempts yet
Problem
This problem is the same as "Quadrat Survey (Hard)" except for the limits on and .
Sejong is doing a practical assignment on quadrat surveys. A quadrat is a grid, and its cells are numbered 1 to in order. Each cell has one flower in bloom. Sejong's world has billion kinds of flowers, numbered from 1 to by kind. Sejong must count how many flowers of a given kind bloom in a range that his teacher assigns. The teacher changes the ranges often, so Sejong gets annoyed and decides to trample the flowers.
Write a program that handles the following queries for Sejong's assignment.
1 l r k: Print the number of flowers of kind among the flowers in cells to of the quadrat.2 l r: Sejong tramples the flowers in cells to of the quadrat, removing them.
Input
The first line contains a positive integer , the size of the quadrat. ()
The second line contains positive integers , separated by spaces. is the kind of flower in cell . ()
The third line contains a positive integer , the number of queries. ()
From the fourth line on, each of the lines contains one query. (; )
At least one query of type 1 is given.
Output
For each query of type 1, print the answer on its own line.