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 |
1 |
Correct |
43 ms |
19064 KB |
Output is correct |
2 |
Correct |
58 ms |
18864 KB |
Output is correct |
3 |
Correct |
42 ms |
18924 KB |
Output is correct |
4 |
Correct |
42 ms |
18800 KB |
Output is correct |
5 |
Correct |
43 ms |
19160 KB |
Output is correct |
6 |
Correct |
46 ms |
19316 KB |
Output is correct |
7 |
Correct |
56 ms |
19432 KB |
Output is correct |
8 |
Correct |
50 ms |
19328 KB |
Output is correct |
9 |
Correct |
46 ms |
19436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
19316 KB |
Output is correct |
2 |
Correct |
53 ms |
19076 KB |
Output is correct |
3 |
Correct |
46 ms |
19024 KB |
Output is correct |
4 |
Correct |
44 ms |
18824 KB |
Output is correct |
5 |
Correct |
47 ms |
19076 KB |
Output is correct |
6 |
Correct |
49 ms |
18912 KB |
Output is correct |
7 |
Correct |
45 ms |
18908 KB |
Output is correct |
8 |
Correct |
48 ms |
19380 KB |
Output is correct |
9 |
Correct |
53 ms |
19096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
19064 KB |
Output is correct |
2 |
Correct |
58 ms |
18864 KB |
Output is correct |
3 |
Correct |
42 ms |
18924 KB |
Output is correct |
4 |
Correct |
42 ms |
18800 KB |
Output is correct |
5 |
Correct |
43 ms |
19160 KB |
Output is correct |
6 |
Correct |
46 ms |
19316 KB |
Output is correct |
7 |
Correct |
56 ms |
19432 KB |
Output is correct |
8 |
Correct |
50 ms |
19328 KB |
Output is correct |
9 |
Correct |
46 ms |
19436 KB |
Output is correct |
10 |
Correct |
52 ms |
19316 KB |
Output is correct |
11 |
Correct |
53 ms |
19076 KB |
Output is correct |
12 |
Correct |
46 ms |
19024 KB |
Output is correct |
13 |
Correct |
44 ms |
18824 KB |
Output is correct |
14 |
Correct |
47 ms |
19076 KB |
Output is correct |
15 |
Correct |
49 ms |
18912 KB |
Output is correct |
16 |
Correct |
45 ms |
18908 KB |
Output is correct |
17 |
Correct |
48 ms |
19380 KB |
Output is correct |
18 |
Correct |
53 ms |
19096 KB |
Output is correct |
19 |
Correct |
47 ms |
19048 KB |
Output is correct |
20 |
Correct |
47 ms |
19080 KB |
Output is correct |
21 |
Correct |
41 ms |
18728 KB |
Output is correct |
22 |
Correct |
53 ms |
18732 KB |
Output is correct |
23 |
Correct |
40 ms |
18856 KB |
Output is correct |
24 |
Correct |
46 ms |
18936 KB |
Output is correct |
25 |
Correct |
43 ms |
18872 KB |
Output is correct |
26 |
Correct |
47 ms |
18948 KB |
Output is correct |
27 |
Correct |
41 ms |
18736 KB |
Output is correct |