J. Forbidden Word
- Giới hạn thời gian
- 1,0 s
- Giới hạn bộ nhớ
- 256 MB
- Điểm
- 1một phần
- Tỉ lệ AC
- 35,4%
- Người giải
- 90
Censoring bad words is an important feature in chat applications to maintain a respectful and clean community. Your task is to implement a simple version of this feature.
Given a string and
forbidden words, replace every occurrence of a forbidden word in
with asterisks ("*"), keeping the original word length. The replacement should be case-insensitive, meaning variations like "ok", "OK", "oK", and "Ok" should all be replaced with "**".
Input
- The first line contains a string
, which may contain uppercase and lowercase English letters and spaces.
- The second line contains an integer
, representing the number of forbidden words.
- The third line contains
forbidden words, separated by spaces. Each forbidden word consists only of lowercase English letters and has a length between
and
.
Output
- Print the modified string
after replacing all occurrences of forbidden words with asterisks ("*"), preserving their original length. The replacement must be case-insensitive.
Sample
Sample Input 1
nice to meet you
2
NICE meeSample Output 1
**** to meet you
Bình luận