3 a1b2c3d4 Linle@ACM ^~^@^@!%
NO YES NO
import java.util.Scanner; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int m = scanner.nextInt(); scanner.nextLine(); while (m-- != 0) { String pwd = scanner.nextLine(); if (pwd.length() < 8 || pwd.length() > 16) { System.out.println("NO"); continue; } int count = 0; if (Pattern.compile("[A-Z]").matcher(pwd).find()) { count++; } if (Pattern.compile("[a-z]").matcher(pwd).find()) { count++; } if (Pattern.compile("[0-9]").matcher(pwd).find()) { count++; } if (Pattern.compile("[~!@#$%^]").matcher(pwd).find()) { count++; } System.out.println(count >= 3 ? "YES" : "NO"); } } }