111. Word Subsitution

Codeforces
IDCF10269111
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
In this question you must encrypt or decrypt a message by replacing a key letter with a word or a key word with a letter. If the message contains the key word then you should be decrypting and replacing the key word with the key letter. If the message given does not contain the key word then you should be encrypting and should be replacing the key letter with the key word. The key letter will not be within the key word. The first line will be the text you are encrypting or decrypting. The second line will be the key letter and the third line will be the key word. Print the encrypted or decrypted text ## Input The first line will be the text you are encrypting or decrypting. The second line will be the key letter and the third line will be the key word. ## Output Print the encrypted or decrypted text [samples]
**Definitions** Let $ M $ be the input message (string). Let $ c \in \Sigma $ be the key letter (single character). Let $ w \in \Sigma^* $ be the key word (string), with $ c \notin w $. **Constraints** - $ c $ is a single character. - $ w $ is a non-empty string not containing $ c $. **Objective** If $ w \subseteq M $ (i.e., $ w $ is a substring of $ M $):   Decrypt: replace every occurrence of $ w $ in $ M $ with $ c $. Else:   Encrypt: replace every occurrence of $ c $ in $ M $ with $ w $. Output the resulting string.
API Response (JSON)
{
  "problem": {
    "name": "111. Word Subsitution",
    "description": {
      "content": "In this question you must encrypt or decrypt a message by replacing a key letter with a word or a key word with a letter. If the message contains the key word then you should be decrypting and replaci",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269111"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "In this question you must encrypt or decrypt a message by replacing a key letter with a word or a key word with a letter. If the message contains the key word then you should be decrypting and replaci...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ M $ be the input message (string).  \nLet $ c \\in \\Sigma $ be the key letter (single character).  \nLet $ w \\in \\Sigma^* $ be the key word (string), with $ c \\notin w $.  \n\n**Con...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments