DAPC24-067.Expected Error
Medium · 1 s · 256 MB
- icpc
- dapc
- 2024
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.
1. Continue to type the rest of your password.
2. Press backspace to delete the last character and type the rest of your password.
3. 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.
Giriş formatı
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.
Çıxış formatı
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.
Qeyd
Source: Delft Algorithm Programming Contest 2024 · Author: Mike de Vries · License: CC BY-SA 4.0 · Original: https://dapc.wisv.ch · Statement adapted for AlgoLens and shared under the same license. · 8 of the 128 original test cases (the largest) are omitted here to keep the problem lightweight.
Nümunələr
Giriş #1
10 8 20
Çıxış #1
continue
Giriş #2
10 8 80
Çıxış #2
backspace
Giriş #3
10 2 50
Çıxış #3
restart
Giriş #4
10 4 55
Çıxış #4
restart