#P12278. Password Strength Evaluation

    ID: 14387 Type: Default 1000ms 256MiB

Password Strength Evaluation

Password Strength Evaluation

This problem involves designing a password strength evaluator for a user management system. A valid password must consist solely of the following characters:

  • Uppercase letters (A-Z)
  • Lowercase letters (a-z)
  • Digits (0-9)
  • Special characters from the set: ~!@#$%^&*()_ (whose ASCII codes are \(126, 33, 64, 35, 36, 37, 94, 38, 42, 40, 41, 95\) respectively)

The strength of a password is determined as follows:

  1. Strong password (output 3): The password length is at least \(12\) and either:
    • It contains all four character types: uppercase letters, lowercase letters, digits, and special characters, or
    • It contains exactly three types with special characters being one of them and the number of distinct special characters is at least \(3\).
  2. Medium password (output 2): The password length is at least \(8\), is not a strong password, and it contains at least two of the four character types.
  3. Weak password (output 1): The password length is at least \(6\) and it is neither strong nor medium.
  4. Illegal password (output 0): If the password does not meet the above conditions or contains characters not in the allowed set.

Input consists of multiple lines, each line containing one string. For each input, output a single integer (0, 1, 2, or 3) on a separate line corresponding to the evaluation described above.

inputFormat

The input contains multiple lines. Each line is a string representing a password.

outputFormat

For each input line, output a single number on a separate line representing the evaluation of the password:

  • 0: Illegal password
  • 1: Weak password
  • 2: Medium password
  • 3: Strong password

sample

abc
0

</p>