1395 Name Lookup

Source: Internet
Author: User

There is a list, but when you read it, it feels dizzy. Is this a list? All strings are strings without spaces. Now, you need to know whether every name in this list may exist ...... (Check whether spelling is correct)

The specific check method is as follows:

You have a dictionary that contains two parts: the last name and the first name;

You can select one from the two parts to connect them to a "string"-because there is no space on the "list" string! What's more, each word in the dictionary is capitalized (the name is like this), but this "list" does not exist, all of which are lowercase letters!

Well, if any combination appears in the "list", the name in the "list" is valid.

Now you want to check the entire list. If all the items are valid, the output value is 0;

Otherwise, an invalid "name" Q is output, and an invalid "name" is output for each row in the following Q rows ";

The output order is in the order of names in the input "list;


The first line of the input contains an integer, indicating that there are N "names" that need to be checked;

Each line in the following n rows contains a string, indicating that the n names are composed of lowercase letters without spaces;

The next line contains two integers, p and q, indicating the total number of words in the last name and name of the dictionary respectively;

The following p and q lines give the p + q words respectively, and remember that the first letter is uppercase;


Output according to the requirements of the topic description;




Simulation questions

# Include <stdio. h> # include <string. h> main () {int number; int I, m, n; Int J, K, flag, Count, up; char a [10000] [500]; char Xing [1000] [500]; char Ming [1000] [500]; char temp [1000]; int correct [1000]; scanf ("% d ", & number); for (I = 0; I <number; I ++) {scanf ("% s", & A [I]);} scanf ("% d", & M, & N); for (I = 0; I <m; I ++) {scanf ("% s ", & Xing [I]); Xing [I] [0] + = 32 ;}for (I = 0; I <n; I ++) {scanf ("% s", & Ming [I]); Ming [I] [0] + = 32;} up = 0; for (I = 0; I <number; I ++) {f Lag = 1; Count = 1; for (j = 0; j <m; j ++) {for (k = 0; k <n; k ++) {strcpy (temp, Xing [J]); strcat (temp, Ming [k]); If (strcmp (temp, a [I]) = 0) {flag = 0; Count = 0; break;} elsecontinue;} If (flag = 0) break;} If (count! = 0) {correct [Up] = I; up ++;} If (up = 0) printf ("0 \ n "); else {printf ("% d \ n", up); for (I = 0; I <up; I ++) printf ("% s \ n ", A [correct [I]);}


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.