#K64237. Email Validation

    ID: 31931 Type: Default 1000ms 256MiB

Email Validation

Email Validation

Given an email address, your task is to determine whether it is valid. An email address is considered valid if it meets the following criteria:

  • It contains exactly one '@' symbol separating the local part from the domain.
  • The local part consists of alphanumeric characters and may include '.', '_' or '-' provided that these symbols are not consecutive, and they do not appear at the beginning or end.
  • The domain part consists of alphanumeric characters and may include '-' or '.', but these symbols cannot be consecutive. The domain must include a dot separating it from the top-level domain (TLD).
  • The TLD must have at least 2 alphabetic characters.

If the email address is valid according to the above rules, output \(1\); otherwise, output \(0\).

inputFormat

A single line from standard input containing an email address string.

outputFormat

A single integer printed to standard output: 1 if the email address is valid; otherwise, 0.## sample

example.user@domain.com
1

</p>