#C5303. Email Template Processor
Email Template Processor
Email Template Processor
This problem involves processing email template requests. Given a dataset that includes several email templates and corresponding email requests, your task is to substitute placeholder tokens within these templates with actual values provided in the requests. Each template consists of a subject and some placeholders.
You are required to output the final email by printing the template's subject followed by its associated values, each on a new line. Separate different email outputs with an empty line.
inputFormat
The input is provided via standard input (stdin) in a space-separated format. The first token is an integer T that specifies the number of templates. Following that, for each template, the subject (a string) is given, followed by an integer P that indicates the number of placeholders, and then P placeholder tokens (strings). After the templates, an integer R is provided which indicates the number of email requests. Each request begins with a template id (1-indexed) followed by as many tokens as there are placeholders in that template. For example, a sample input is structured as follows:
T subject1 P placeholder1 ... placeholderP subject2 P placeholder1 ... placeholderP ... R template_id value1 ... valueP ...
Note: All tokens are separated by whitespace.
outputFormat
For each email request, print the email subject on the first line followed by each corresponding value on new lines. Separate outputs for different email requests with a blank (empty) line. The output should be sent to standard output (stdout).## sample
1
2 New_Year_Offer 2 {discount_code} {expiry_date} Meeting_Reminder 1 {date} 3 1 SAVE20 31/12/2023 1 DISCOUNT10 15/01/2024 2 12/11/2023
New_Year_Offer
SAVE20
31/12/2023
New_Year_Offer
DISCOUNT10
15/01/2024
Meeting_Reminder
12/11/2023
</p>