#P12005. Markdown Spacing Validator

    ID: 14108 Type: Default 1000ms 256MiB

Markdown Spacing Validator

Markdown Spacing Validator

You are given a Markdown article of length n composed only of the characters a, @, 1, $, ,, and _. Their meanings are as follows:

  • a: an English letter
  • @: a Chinese character
  • 1: a digit
  • $: a formula (note: the meaning of this symbol is different from the traditional usage)
  • ,: a Chinese punctuation mark
  • _: a half-width (ASCII) space

The article is considered valid if it meets the following conditions:

  1. Whenever a Chinese character (@) and an English letter, digit, or formula (a, 1, or $) occur consecutively in the article (ignoring spaces), they must be separated by a single half-width space. That is, if a Chinese character and an English/digit/formula symbol are adjacent in the text, there must be exactly one _ between them.
  2. Whenever a Chinese punctuation mark (,) and an English letter, digit, or formula appear consecutively (ignoring spaces), there should be no space between them. In other words, there must be no _ inserted between a Chinese punctuation and an English/digit/formula symbol.

If the article satisfies all the rules, output Yes; otherwise, output No.

Note: For the purpose of these rules, only the positions of non-space characters are considered. When checking any two adjacent non-space characters in the original text, examine the substring between them:

  • If one symbol is a Chinese character (@) and the other is an English/digit/formula (a, 1, or $), the gap must be exactly one underscore (_).
  • If one symbol is a Chinese punctuation (,) and the other is an English/digit/formula, the gap must be empty (i.e. no underscore).

Any other adjacent pairs are not restricted.

inputFormat

The input consists of a single line representing the Markdown article, which is a string composed only of the characters a, @, 1, $, ,, and _.

outputFormat

Output a single line: Yes if the article meets the spacing requirements; otherwise, output No.

sample

@_a
Yes