Shil and Round Numbers
Practice
4 (32 votes)
Approved
Bit manipulation
Data structures
Easy
Math
Open
Ready
Problem
60% Success 7087 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Shil likes Round numbers very much . A number is called Round number if its non-negative and its first and last digits are same. For example 0 , 3 , 343 and 50005 are round numbers whereas 1000 is not a round number.
Shil has an array A1 , A2 .. AN . He wants to answer Q queries of following two type :
1 l r : Find total number of round numbers in range [l, r]
2 i K : Update ith element of array A to K i.e perform the operation Ai = K.
Since you are the friend of Shil , he asks for your help .

INPUT:
First line consists of two integers N and Q. Next line consists of N integers A1 , A2 .. AN. Next line consists of Q queries. Each query consists of three integers as mentioned in the problem.

OUTPUT:
For each query of type 2 , output total number of round numbers in range [l,r].

CONSTRAINTS:
1 ≤ N , Q ≤ 2*105
-1018Ai ≤ 1018
1 ≤ l,rN
-1018K ≤ 1018

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
463 votes
Tags:
Ad-HocApprovedBit ManipulationData StructuresEasyFenwick treeSorting
Points:30
7 votes
Tags:
ApprovedData StructuresData compressionEasyFenwick TreeFenwick tree
Points:30
78 votes
Tags:
ApprovedEasyMathOpenReadySegment TreesTrees