이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
def prebroj(s):
molekule = s.split('+')
rj = [0] * 26
for mol in molekule:
broj_molekula = 1
if mol[0].isdigit():
broj_molekula = int(mol[0])
mol = mol[1:]
for i in range(len(mol)):
if mol[i].isdigit():
continue
broj_atoma = 1
if i < len(mol) - 1:
if mol[i + 1].isdigit():
broj_atoma = int(mol[i + 1])
rj[ord(mol[i])-ord('A')] += broj_atoma * broj_molekula
return rj
n = int(input())
for i in range(n):
jed = input()
lijevo, desno = jed.split("->")
broj_l = prebroj(lijevo)
broj_d = prebroj(desno)
if broj_l == broj_d:
print("DA")
else:
print("NE")
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |