ZOJ Problem Set - 1447
WishingBone met a ppmm in school today. He is really enthusiastic to know her name. The only information he's got is her school identity which is on her school bag. At night, WishingBone broke into the office of the principal, and found a long long list of all the students' names. It reads:
1: WishingBone ID: green_bone blue_bone red_bone
And he remembers the ppmm's ID is white_bone blue_bone greed_bone. Of course, he did not want to read the list through to find this ID. Well, fortunately, he found a piece of code in the recycled bin that the principle used to generate those ID's. This program reads in m and n, where m is the number of color of bones and n is the length of the ID. Then it reads in a list of colors and generates the list of possible ID's. Since WishingBone is quite poor at programming, he resorts to your help.
Input consists of multiple tests. Each test starts with a line of m and n (0 < n <= m <= 12), and a list of m distinct names of colors on the next line, separated by a single space. Names are made up of up to 30 upper, lower Latin characters and the '_' character. The third line of a test contains a sequence of n names of colors, which is the school identity of the ppmm.
Process to the end of file. There will be no more than 10000 tests.
For each test in the input, output a single integer - the line on which to find her name.
The Program WishingBone found in the pricipal's office:
void FAINT(int m,int n,int l,int a[MAXN],int t,char name[MAXN],int&
void faint(int m,int n,int l,int a[MAXN],int t,char name[MAXN],int&
Source: WishingBone's Contest #1