Decipherability
SRM 649 · 2015-01-29 · by tozangezan
Problem Statement
For example, suppose that s="snuke" and K=2. Snuke removed two characters and showed you the string "nue". In this situation you can easily deduce that Snuke must have removed the characters s[0] and s[3]. You announce that the indices of removed characters are 0 and 3, and you win the game.
You are given the
Constraints
- K will be between 1 and 50, inclusive.
- The length of s will be between K and 50, inclusive.
- Every character in s will be a lowercase letter ('a'-'z').
"snuke" 2 Returns: "Certain"
This is the example from the problem statement. As all characters are unique, you can always determine the indices of the erased ones.
"aba" 1 Returns: "Certain"
Snuke will show you one of the strings "ba", "aa", and "ab". In the first case you can be sure that he erased the character at index 0. The second and the third string correspond to indices 1 and 2, respectively.
"aba" 2 Returns: "Uncertain"
If Snuke shows you the string "a", there are two possibilities: either he erased the characters at indices 0 and 1, or the characters at indices 1 and 2.
"abcdabcd" 3 Returns: "Certain"
"koukyoukoukokukikou" 2 Returns: "Uncertain"
Submissions are judged against all 118 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Decipherability with a public method string check(string s, int K) · 118 test cases · 2 s / 256 MB per case