import java.io.PrintWriter; import java.util.HashSet; import java.util.Scanner; public class Main { static PrintWriter cout = new PrintWriter(System.out, true); static Scanner cin = new Scanner(System.in); static final char[] chs = {‘~‘,‘!‘,‘@‘,‘#‘,‘$‘,‘%‘,‘^‘}; static boolean isChar(char ch) { for(int i = 0; i < chs.length; i++) if(chs[i] == ch) return true; return false; } public static void main (String[] args){ int t = cin.nextInt(); while(t-- > 0) { String s = cin.next(); if(!(s.length()>=8&&s.length()<=16)) { cout.println("NO"); continue; } int i = 0; HashSet<String> set = new HashSet<String>(); while(i < s.length()) { if(‘0‘<=s.charAt(i)&&s.charAt(i)<=‘9‘) { set.add("1"); } else if(‘a‘<=s.charAt(i)&&s.charAt(i)<=‘z‘) { set.add("2"); } else if(‘A‘<=s.charAt(i)&&s.charAt(i)<=‘Z‘) { set.add("3"); } else if(isChar(s.charAt(i))) { set.add("4"); } if(set.size() >= 3) { break; } i++; } if(set.size() >= 3) cout.println("YES"); else cout.println("NO"); } } }
时间: 2024-11-03 22:30:04