#P2264. Quantifying the Emotional Impact of a Love Letter
Quantifying the Emotional Impact of a Love Letter
Quantifying the Emotional Impact of a Love Letter
In order to help CYY, we define an emotional impact value for a love letter. The value is computed as follows:
- For each sentence in the letter (sentences are delimited by an English period
.
), check if it contains any of the given keywords. For each keyword present in the sentence, add1
to the emotional impact value. If a keyword appears multiple times in the same sentence, it is counted only once. Different keywords in the same sentence contribute separately. - The text is case-insensitive.
In mathematical notation, if a sentence S is processed and there are k keywords, then the contribution of that sentence is given by:
$$ \text{score}(S)=\sum_{i=1}^{k} \mathbb{1}_{\{\text{keyword}_i \in S\}}, $$and the total emotional impact is the sum of the scores for all sentences.
inputFormat
The input consists of two lines:
- The first line contains the list of unique keywords separated by spaces.
- The second line contains the text of the love letter. Sentences in the text are delimited by an English period
.
.
The text is not case-sensitive.
outputFormat
Output a single integer representing the total emotional impact value computed based on the rules described above.
sample
love romance
I love you. You are my romance.
2