#P8410. Magic Value Chat
Magic Value Chat
Magic Value Chat
You are given \( n \) pieces of information, each following one of three types. Each information is represented as one of the following formats:
<str>:
— indicates that the next line contains a message sent by the user with name \( str \)./<str>
— represents an emoticon message with name \( str \).<str>
— represents a text message with content \( str \).
It is observed that emoticon messages with the names oh
and hsh
exhibit a magical effect. In a conversation:
- Each emoticon message
/<oh>
increases the magic value by \( a \). - Each emoticon message
/<hsh>
increases the magic value by \( b \). - All other messages do not affect the magic value. The initial magic value is \( 0 \).
Your task is to calculate the total magic value after processing all \( n \) messages.
inputFormat
The first line contains three integers \( n \), \( a \), and \( b \) separated by spaces.
The following lines contain the \( n \) pieces of information. Note that if a line ends with a colon (:
), it indicates that the next line is a message sent by the user whose name is specified. For a line starting with /<
and ending with >
, it represents an emoticon message. All string tokens do not contain spaces, the characters ':' and '/', and the angle brackets are used only as delimiters.
outputFormat
Output a single integer, the total magic value.
sample
3 10 20
/
/
30