Easier Done Than Said?Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16443 Accepted Submission(s): 7807 Problem Description Password security is a tricky thing. Users prefer simple passwords that are easy to remember (like buddy), but such passwords are often insecure. Some sites use random computer-generated passwords (like xvtpzyo), but users have a hard time remembering them and sometimes leave them written on notes stuck to their computer. One potential solution is to generate "pronounceable" passwords that are relatively secure but still easy to remember. Input The input consists of one or more potential passwords, one per line, followed by a line containing only the word 'end' that signals the end of the file. Each password is at least one and at most twenty letters long and consists only of lowercase letters. Output For each password, output whether or not it is acceptable, using the precise format shown in the example. Sample Input a tv ptoui bontres zoggax wiinq eep houctuh end Sample Output <a> is acceptable. <tv> is not acceptable. <ptoui> is not acceptable. <bontres> is not acceptable. <zoggax> is not acceptable. <wiinq> is not acceptable. <eep> is acceptable. <houctuh> is acceptable. |
package hdu.oi;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String c;
Scanner sc=new Scanner(System.in);
while(sc.hasNext()) {
int flag=1;
int vowel=0;
c=sc.next();
if(c.compareTo("end")==0) return ;
int l=c.length();
int[] a=new int[l];
for(int i=0;i<l;i++) {
if(c.charAt(i)=='a'||c.charAt(i)=='e'||c.charAt(i)=='i'||c.charAt(i)=='o'||c.charAt(i)=='u') {
a[i]++;
vowel=1;
}
else
a[i]+=2;
if(i<l-1&&c.charAt(i)==c.charAt(i+1)&&c.charAt(i)!='e'&&c.charAt(i)!='o') {
flag=0;
}
}
for(int i=1;i<l-1;i++) {
if(a[i]==a[i-1]&&a[i]==a[i+1])
flag=0;
}
if(flag==1&&vowel==1)
System.out.println('<'+c+'>'+" is acceptable.");
else
System.out.println('<'+c+'>'+" is not acceptable.");
}
}
}