RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00617

Kemija

Unrated 레이팅 미적용
난이도
1s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Fran didn’t pay attention in school during chemistry class and now he needs your
help in doing his homework. His homework consists of \(n\) chemical equations for
which he needs to check if they are balanced. A chemical equation is a way of
representing chemical reactions using symbols and formulas. In a chemical reaction,
some set of initial molecules react to produce a new set of molecules.
A chemical equation has a left side and a right side. The left side contains chemical
formulas of the initial molecules, while the right side contains chemical formulas of the product molecules.
The left and the right sides of the equation are separated by an arrow (characters ->). Different molecules
appearing on the left or the right side are separated by a +.
Molecules are substances made from atoms, tiny particles which are denoted with capital letters of the
Latin alphabet (for the purposes of this task). The formula of a molecule is written by listing the labels of
all the different atoms which make up the molecule. If a molecule has multiple instances of some atom,
then the number of occurrences of this atom is written after the atom in the formula. For example, AC4B
is a formula for a molecule which has one atom A, 4 atoms C and one atom B. If on one side of the equation
a molecule appears more than once, then this number of occurrences is written as a coefficient in front of
the formula. For example, 3AC4B denotes 3 molecules of AC4B, for a total of 3 atoms A, 12 atoms C and 3
atoms B.
A chemical equation is said to be balanced if the right side and the left side contain an equal number of
atoms of each kind. Your task is to determine whether or not each of the \(n\) chemical equations is balanced.
The test cases will be such that all the numbers appearing in the reactions (the numbers of atoms in
molecules and the numbers of molecules in the ractions) will have only a single digit (and they will be
larger than 1).

제약

Subtask 1 (10 points): No chemical reaction has a number in it.

Subtask 2 (10 points): No numbers appear within any formulas for molecules.

Subtask 3 (30 points): No additional constraints.

입력 형식

The first line contains a positive integer \(n\) (\(1 \le n \le 10\)), the number of chemical equations.
Each of the next \(n\) lines contains a sequence of characters representing a chemical equation. Each equation
consists of at most 1000 characters. The equations will not necessarily be balanced, but they will be
correctly written as described in the statement.

출력 형식

For each of the \(n\) equations print DA if it is balanced, and NE if it is not, in separate lines.

서브태스크
서브태스크점수설명

1

10점

No chemical reaction has a number in it.

2

10점

No numbers appear within any formulas for molecules.

3

30점

No additional constraints.

예제 1
입력
3
A+B->AB
AB+CD->AC+DB
AB+B->AB
출력
DA
DA
NE
예제 2
입력
2
2AB+A->3AB
2AB+2AC+2BC->4ABC
출력
NE
DA
예제 3
입력
4
2H2O+2CO2->2H2CO3
H2SO4->H2O4
NH3+H2SO4->NH4SO4
CH4+2O2->CO2+2H2O
출력
DA
NE
NE
DA
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2021/2022 Contest 5

평가 및 의견

Kemija

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Kemija

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8