Safe
Time limit1sMemory limit1024 MB
Two equal-length numbers get digits appended and removed from the right, and each query asks for one digit of their sum.
Problem
Archaeologists found a safe on an old ship. Its digital lock has a screen that shows two integers of equal length, and these numbers change from time to time. The screen changes in three ways:
- One digit is appended to the right of each number.
- Some number of digits disappears from the right of both numbers.
- A third number appears on the screen, next to an input field that takes a single digit.
The researchers suspect that the safe opens when you enter the digit of the sum of the two large numbers at the position given by the third number. The numbers change too fast to compute by hand, so they need a program that answers these queries.
The main component is a library that reacts to events on the safe's screen. The functions below are called times in total.
The test environment provides example files where the required functions are already declared, so you only need to write the implementations in your solution. You may also write your own functions in the solution file. The language is C++ and the solution file is seif.cpp. To compile and test on your own computer, use the following commands.
g++ -o main main.cpp seif.cpp
./main
A sample grader is provided for local testing. The server uses a different grader that also checks whether the answers returned by your solution are correct.
Input
The first line of the input file contains the number of library function calls (). Each of the next lines describes one call in one of the following forms.
1 F S(, ) is the callAdd(f, s).2 K() is the callDel(k).3 P() is the callGet(p).
Output
The output file contains a log of the interaction between the grader and the library.