In the (B) option, second resonance structure is supposed to be valid.
But according to my textbook, many adjacent charges would make the resonance structure too unstable and hence it would not be accepted as a valid resonance structure.
Resonance formulae differ by localizing the electrons with dashes, plus and minus signs. Thus correct, B is the sole line matching the criterion.
This contrasts, e.g. with line A depicts what is known as keto-enol isomers, which is: a change of how atoms are connected with each other. Here, keto-O once binds (or not) to an hydrogen. See guides, for example here.
Some of the forms may appear «high energy» for, e.g. writing charges in one form, but not the other. As in the example of diazomethane, line B, or with DMSO:
The mere presence of atoms with a charge in one resonance formula does not render the formula wrong, but -- compared to the form without charges -- may represent a lesser or minor contribution to the overall structure represented, than the other. In decreasing priority, there is a set of rules to consider. To quote from Wikipedia, formulae must
- obey as much as possible the octet rule [...]
- have a maximum number of covalent bonds;
- carry a minimum of formally charged atoms, with the separation for unlike and like charges minimized and maximized, respectively;
- place negative charge, if any, on the most electronegative atoms and positive charge, if any, on the most electropositive;
- do not deviate substantially from idealized bond lengths and angles [...]
- maintain aromatic substructures locally while avoiding anti-aromatic ones [...]
You will encounter nitro group's Lewis formula as a potential pitfall searching in databases, too.