BreakingTheCode
SRM 397 · 2008-04-12 · by mateuszek
Problem Statement
You have been given a secret mission where you must break the enemy's code. You have already figured out that they encode messages using the following method. Each letter between 'a' and 'z', inclusive, is assigned a distinct two-digit number between 01 and 26, inclusive. A message is encoded by simply replacing each letter with its assigned number. For example, if 't' is assigned 20, 'e' is assigned 05 and 's' is assigned 19, then the message "test" is encoded as "20051920". All original messages contain only lowercase letters.
You are given a
Constraints
- code will contain exactly 26 characters.
- Each lowercase letter between 'a' and 'z', inclusive, will occur exactly once in code.
- message will contain between 1 and 50 characters, inclusive.
- message will either contain only lowercase letters ('a'-'z') or only digits ('0'-'9').
- If message contains only digits, it will be a concatenation of two-digit numbers, each between 01 and 26, inclusive.
"abcdefghijklmnopqrstuvwxyz" "test" Returns: "20051920"
Example from the problem statement. Here, the letters are coded in an alphabetical order.
"abcdefghijklmnopqrstuvwxyz" "20051920" Returns: "test"
Now, we're decoding it.
"qesdfvujrockgpthzymbnxawli" "mwiizkelza" Returns: "19242626171202251723"
"ghrnbwvoekdtfuqsycmizalpxj" "bfapgbyqgi" Returns: "05132224010517150120"
"hxkaqjvybrtpfwcedglunszmoi" "vmxnshxdgo" Returns: "07240221220102171825"
Submissions are judged against all 76 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class BreakingTheCode with a public method string decodingEncoding(string code, string message) · 76 test cases · 2 s / 256 MB per case