luogu#P8410. 「SvR-1」Don't Mozheng. /oh

    ID: 7651 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>模拟2022洛谷原创O2优化洛谷月赛

「SvR-1」Don't Mozheng. /oh

Background

Problem Number: 58\textit{58}.

In the Guluo Academic group chat, everyone is getting "mozheng" (魔怔).

The Luogu blog post "Introduction to Mozheng": https://www.luogu.com.cn/blog/supervise/how-to-get-a-mz.

If you need the PDF of "Introduction to Mozheng" (currently updated to version v1.1.1), please download it from "Problem Attachments" below.

Problem Description

You are given nn messages. There are three types of messages (note that <str>\texttt<\textit{str}\texttt> describes a string named strstr. This string contains no spaces, and does not contain the characters :\texttt: or /\texttt/. It also does not include the angle brackets on either side):

  1. In the form <str>:\texttt<\textit{str}\texttt{>:}. This means that the single message on the next line is sent by the user named strstr.
  2. In the form /<str>\texttt{/<}str\texttt> This means an emoji message with name strstr.
  3. In the form <str>\texttt<\textit{str}\texttt>. This means a text message whose content is strstr.

After long observation, you found that the emoji messages named oh\texttt{oh} and hsh\texttt{hsh} have a "mozheng" meaning.

Also, within a conversation:

  • One oh\texttt{oh} emoji increases the mozheng value by aa.
  • One hsh\texttt{hsh} emoji increases the mozheng value by bb.
  • Any other message will not affect the mozheng value, and the initial mozheng value is 00.

Now, for these messages, you need to compute the total mozheng value.

Input Format

The first line contains three integers n,a,bn,a,b, meaning there are nn messages in total, and a,ba,b are as described above.

The next 2×n2\times n lines describe each message:

  • The first line is a type 1 message.
  • The second line is a type 2 or type 3 message.

Output Format

Output one integer on a single line, the total mozheng value.

7 1 2020
wop:
/yueliang
eoq:
wop_loushang
wop:
eoq_npy_when
eoq:
/oh
dek:
/oh
rif:
NOI2022_rp_++
rif:
/hsh
2022

Hint

Explanation for Sample 1

As shown in the figure.

Constraints

This problem uses bundled testdata.

Let ll be the maximum length of a single-line message in the input.

$$\newcommand{\arraystretch}{1.5} \begin{array}{c|c|c|c}\hline\hline \textbf{Subtask} & \bm{n\le} & \textbf{Special Property} & \textbf{Score} \\\hline \textsf{1} & \le 10 & - & 20 \\\hline \textsf{2} & \le 100 & - & 20 \\\hline \textsf{3} & \text{No special limit} & \text A & 20 \\\hline \textsf{4} & \text{No special limit} & - & 40 \\\hline\hline \end{array}$$
  • Special property A\text{A}: The input does not contain type 3 messages.

For 100%100\% of the data, 1n1041\le n\le 10^4, 1l501\le l\le 50, 1a,b1031\le a,b\le 10^3.

Translated by ChatGPT 5