Retrieve passwords
Practice
3.2 (9 votes)
Advanced data structures
Data structures
Fenwick tree
Segment trees
Problem
81% Success 923 Attempts 30 Points 1s Time Limit 512MB Memory 1024 KB Max Code
A password is a number that is exactly divisible by 9. It is the largest number that can be formed by rearranging all the available digits in a provided range (
- Update a digit at a position.
- Determine the largest number that is divisible by 9 in the provided range with the mentioned conditions. In the provided mentioned number, print its
digit.
You must retrieve the password.
Input format
- First line: A string
- Second line: A number
indicating the number of questions that must be asked - Third line:
- For each
:- A number
indicating the type of query 1 to update and 2 for the query - For a query of type 1, two numbers follow
and .
Update the value at position (1-based indexing) to . - For a query of type 2, three numbers follow
, , .
Determine the digit between to inclusive (1-based indexing) for the retrieved password.
- A number
- For each
Output format
For each query of type 2, print the
Constraints
\(|s|\le 10^6\
q\le 5 \times 10^5\
0
Explanation
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
21 votes
Tags:
DatastructuresFenwick (Binary Indexed) TreesInversion CountFenwick TreeAdvanced Data StructuresData StructuresSegment tree
Points:30
8 votes
Tags:
Advanced Data StructuresAlgorithmsData StructuresFenwick TreeMediumOpen
Points:30
59 votes
Tags:
ApprovedBit ManipulationData StructuresMediumOpenReadyString Manipulation
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Results
Custom Input
Run your code to see the output