Expected Error
면접 대비시간 제한1초메모리 제한1024 MB
비밀번호 길이 n, 정확히 입력한 문자 수 k, 잘못된 키를 눌렀을 확률 p가 주어질 때 continue, backspace, restart 중 기대 완료 시간이 가장 짧은 전략을 고른다.
문제
You are typing your password at a sudo prompt, but suddenly, one of your fingers slipped onto a wrong key. Because the terminal hides the characters that you type, you are uncertain whether you have typed an extra character. To finish typing your password, you consider three possible strategies.
- Continue to type the rest of your password.
- Press backspace to delete the last character and type the rest of your password.
- Restart typing your password from scratch.
To determine the optimal strategy, make use of the following typing speed assumptions.
- Typing any character of your password takes seconds.
- Pressing backspace or submitting your password also takes seconds.
- To restart typing your password, you delete all characters, which takes seconds.
- If you submit the wrong password, it takes an additional seconds to realize and start typing your password at a new, empty prompt.
You are given the number of characters in your password , the number of correctly typed characters before your finger slipped, and a probability of indicating the likelihood that you pressed a wrong key and ended up with characters. Assuming you make no further errors, determine which strategy yields the lowest expected time to finish typing your password.
입력
The input consists of:
- One line with three integers , , and (, , ), the number of characters in your password, the number of characters you correctly typed before your finger slipped, and the probability percentage that you pressed a wrong key.
출력
Output one of the strings "continue", "backspace", or "restart" indicating the optimal strategy. It is guaranteed that the expected time of the optimal strategy is at least one millisecond shorter than the other strategies.