O-molecular mass
On a square table consisting of N x N smaller squares, professor Mira wrote some number of chemical compounds using structural formulas. The first student that calculates the largest molecular mass of all the written compounds gets an ”A”! The compounds are organic and consist of atoms C (carbon-12), O (oxygen-16), H (Hydrogen-1) and N (Nitrogen-14). Atomic masses of elements are in the brackets.
In 50% of test cases, the compounds will be in seperate rectangular areas.
You don’t have to worry about the atoms’ valence.
11
..H........
..|........
H-C-H......
..|........
..H........
...........
......H-O..
........|..
......H-N-H
...........
...........
Output:
33
8
H-H-H.N.
|C-C|..C
H|O|H.O|
|C-C|N|C
H-H-H|O|
...N-N|C
..O-O-O|
NC-C-C-C
Output:
84
Example 2 has 8 candidates:
2 square compounds: first with 8 atoms of hydrogen and the second with 4 atoms of carbon
3 L-chains: 7 atoms of carbon, 5 atoms of oxygen and 3 atoms of nitrogen
3 atoms: 1 oxygen and 2 nitrogen.
L chain of carbon has the largest mass: 7*12=84.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.