F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Match the string

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 885    Accepted Submission(s): 293


Problem Description
  Sometimes we need to check that if a given string matches a format string or not. Look at the format string: (a)*(b)+(c)?(f|d), * represents the substring in the brackets before appears any times, if the format string is (ab)* ,then string ¡°ababab¡± or null string match the format string .And + represents the substring in the brackets appears one or more times, for the format (ab)+ , the null string can¡¯t match the format string. And the ? represents the substring in the brackets before appears none or once , and when you get the symbol |, either the substring s1(left of the symbol | ) appear once, or the substring s2(right of the symbol) appear once, but they don¡¯t appear together. For example, (f|h) represent that either ¡®f¡¯ or ¡®h¡¯ appears for once.
 

Input
  In the first line, there is N represents the case number. Then N lines follow, in each line, there is a string. The length of each string won¡¯t exceed 100000, and 1<=N<=1000. The letters appear in the string are only lower letters.
 

Output
  The format string is given before and won¡¯t be changed. The format string is (a)*aba((b)?(d)+)?h((f)|(k))+
  For each case, just print ¡°YES¡± if the input string mathes the format string, or ¡°NO¡±.
 

Sample Input
4 abahf aababdddhffkk babbbdh aaaaaaaaabahffffffff
 

Sample Output
YES YES NO YES
 

Author
wangye
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 12:24:50, Gzip enabled