#B. [COCI2021-2022#5] Kemija

    Type: RemoteJudge 1000ms 512MiB

[COCI2021-2022#5] Kemija

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

给定 nn 个化学方程式。

每个参与反应的分子由若干个原子组成,每个原子由一个字母和一个数字表示,分别代表元素名称和分子中该原子的数量。如果多个分子参与反应,则分子前添加一个数字表示化学计量数。本题中只需考虑每一原子的数量,而不必考虑方程式的合理性。例如,3AC4B\texttt{3AC4B} 可以直接视为 33A\texttt A33B\texttt B1212C\texttt C 参与反应。当有不同分子位于方程式同一边时,用 +\texttt + 连接。

你的任务是分别检查每个方程式是否已经配平(只需考虑左右原子数量是否都对应相等)。

输入格式

第一行一个正整数 nn,表示方程式的个数。

接下来的 nn 行,每行一个方程式。数据保证每个方程式字符串长度不超过 10001000,且每个元素都只包含一个大写字母。

输出格式

对于每个方程式,如果已经配平则输出 DA\texttt{DA},否则输出 NE\texttt{NE}

3
A+B->AB
AB+CD->AC+DB
AB+B->AB
DA
DA
NE
2
2AB+A->3AB
2AB+2AC+2BC->4ABC
NE
DA
4
2H2O+2CO2->2H2CO3
H2SO4->H2O4
NH3+H2SO4->NH4SO4
CH4+2O2->CO2+2H2O
DA
NE
NE
DA

提示

【样例 3 解释】

序号 左侧原子 右侧原子 结果
11 $4 \times \texttt H, 6 \times \texttt O, 2 \times \texttt C$ DA\green{\texttt{DA}}
22 $2 \times \texttt H, \red{1 \times \texttt S}, 4 \times \texttt O$ 2×H,4×O2 \times \texttt H, 4 \times \texttt O NE\red{\texttt{NE}}
33 $1 \times \texttt N, \red{5 \times \texttt H}, 1 \times \texttt S, 4 \times \texttt O$ $1 \times \texttt N, \red{4 \times \texttt H}, 1 \times \texttt S, 4 \times \texttt O$
44 $1 \times \texttt C, 4 \times \texttt H, 4 \times \texttt O$ DA\green{\texttt{DA}}

【数据规模与约定】

本题采用捆绑测试。

  • Subtask 1(10 pts):方程式中均不含数字。
  • Subtask 2(10 pts):分子式中均不含数字。
  • Subtask 3(30 pts):无特殊限制。

对于 100%100\% 的数据,1n10001 \le n \le 1000

【来源】COCI 2021-2022#5 Task 1 Kemija。

B班 6_08 训练

Not Attended
Status
Done
Rule
OI
Problem
4
Start at
2024-6-8 9:00
End at
2024-6-8 11:30
Duration
2.5 hour(s)
Host
Partic.
10