#4. 字符串单词替换为加号

    ID: 4 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatString-2gesp3字符串模拟

字符串单词替换为加号

String Replacement with Word Preservation

Background

Congcong is playing a string processing game. He has a long string and wants to perform some special operations on it.

Problem Description

Given a string and a non-empty word string, return a version of the original string where all characters have been replaced by pluses ("+"), except for appearances of the word string which are preserved unchanged.

Input Format

Input is given from standard input in the following format.

S" "W

Output Format

Output is printed to standard output in the following format.

result_string

Sample

12xy34" "xy
"++xy++"
12xy34" "1
"1+++++"
12xy34xyabcxy" "xy
"++xy++xy+++xy"

Sample Explanation

  • Sample 1: For string S = "12xy34" and word W = "xy", xy is preserved, and 12 and 34 are replaced by ++. The result is "++xy++".
  • Sample 2: For string S = "12xy34" and word W = "1", 1 is preserved, and 2xy34 is replaced by +++++. The result is "1+++++".
  • Sample 3: For string S = "12xy34xyabcxy" and word W = "xy", all occurrences of xy are preserved, and other characters are replaced by +. The result is "++xy++xy+++xy".

Constraints

Time limit: 1 second, Memory limit: 1024 KiB for each test case.