#C200. Synonym Substitution

    ID: 45268 Type: Default 1000ms 256MiB

Synonym Substitution

Synonym Substitution

This problem requires you to perform synonym substitution on an input text. In the text, certain words may have synonyms provided in a dictionary, and each word is replaced by one of its synonyms with a given probability.

The substitution is performed word by word. For each word in the input text, if the word appears as a key in the provided synonym dictionary and a random number (between 0 and 1) is less than the given substitution probability, then the word is replaced with one of its synonyms chosen uniformly at random.

For reproducibility, all solution codes must use a fixed seed (42) for the pseudo-random number generator so that the output is deterministic.

The synonym dictionary is provided in JSON format. The input will be read from standard input and the resulting output must be printed to standard output.

inputFormat

The input consists of three lines:

  1. A string representing the text.
  2. A JSON-formatted string representing the synonym dictionary. Each key is a word and its value is an array of synonyms.
  3. A floating-point number representing the substitution probability.

All input is provided via stdin.

outputFormat

Output the text after performing the substitution. The output should be printed to stdout.

## sample
The quick brown fox jumps over the lazy dog
{"quick": ["fast", "swift"], "brown": ["dark-brown", "chocolate"], "lazy": ["idle", "lethargic"]}
0.0
The quick brown fox jumps over the lazy dog