HDU 4287 intelligent IME 37th ACM/ICPC Tianjin division Network Competition 1010 question (water question)

Source: Internet
Author: User
Intelligent ime

Time Limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 399 accepted submission (s): 207

Problem description we all use cell phone today. and we must be familiar with the intelligent English input method on the cell phone. to be specific, the number buttons may correspond to some English letters respectively, as shown below:
2: A, B, C 3: D, E, F 4: G, H, I 5: J, K, L 6: M, N, O
7: P, Q, R, S 8: T, U, V 9: w, x, y, z
When we want to input the word "wing", we press the button 9, 4, 6, 4, then the input method will choose from an embedded dictionary, all words matching the input number sequence, such as "wing", "WHOI", "zhog ". here comes our question, given a dictionary, how many words in it match some input number sequences?

 

Input first is an integer T, indicating the number of test cases. Then t block follows, each of which is formatted like this:
Two integer N (1 <= n <= 5000), m (1 <= m <= 5000), indicating the number of input number sequences and the number of words in the dictionary, respectively. then comes n lines, each line contains a number sequence, consisting of no more than 6 digits. then comes M lines, each line contains a letter string, consisting of no more than 6 lower letters. it is guaranteed that there are neither duplicated number sequences nor duplicated words.

 

Output for each input block, output n integers, indicating how many words in the dictionary match the corresponding number sequence, each integer per line.

 

Sample input1 3 5 46 64448 74 go in night might Gn

 

Sample output3 2 0

 

Source2012 ACM/ICPC Asia Regional Tianjin online

 

Recommendliuyiding A lot of questions... Even if the problem is solved, the problem cannot be solved .... It's easy.
# Include <stdio. h> # Include <Algorithm> # Include < String . H>Using   Namespace  STD;  Int Num [ 2000000  ];  Int CC ( Char  STR []) {  Int Len = Strlen (STR );  Int Ans = 0  ;  For ( Int I = 0 ; I <Len; I ++ ) {Ans * = 10  ;  If (STR [I] = '  A  ' | STR [I] = '  B  ' | STR [I] = '  C  ' ) Ans + = 2 ;  Else   If (STR [I] = '  D  ' | STR [I] = '  E  ' | STR [I] = '  F  ' ) Ans + = 3  ;  Else   If (STR [I] ='  G  ' | STR [I] = '  H  ' | STR [I] = '  I  ' ) Ans + = 4  ;  Else   If (STR [I] = '  M  ' | STR [I] ='  N  ' | STR [I] = '  O  ' ) Ans + = 6  ;  Else   If (STR [I]> = '  P  ' & STR [I] <= '  S  ' ) Ans + =7  ;  Else   If (STR [I]> = '  T  ' & STR [I] <= '  V  ' ) Ans + = 8  ;  Else   If (STR [I]> = '  W ' & STR [I] <= '  Z  ' ) Ans + = 9  ;  Else Ans + = 5  ;}  Return  Ans ;}  Int A [ 10000  ];  Char STR [ 20 ];  Int  Main (){  Int  T;  Int  N, m; scanf (  "  % D  " ,& T );  While (T -- ) {Scanf (  "  % D  " , & N ,&M); memset (Num,  0 , Sizeof  (Num ));  For ( Int I = 0 ; I <n; I ++ ) {Scanf (  "  % D  " ,& A [I]);}  While (M -- ) {Scanf ( "  % S  " ,& Str); num [CC (STR)] ++ ;}  For ( Int I = 0 ; I <n; I ++ ) Printf (  "  % D \ n  "  , Num [A [I]);}  Return   0 ;} 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.