HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50766 - Word Puzzle

Guest
• Review clarifications (1)

Volume problems

• 50657 - Permutations and Combinat...
• 51246 - Swap largest word, reverse ...
• 51069 - Last Digit of a Fibonacci Nu...
• 50659 - Covariance Matrix
• 50977 - Gaussian Elimination
• Word Puzzle
• 50748 - Gold Store
• 50658 - The Message
• 50766 - Word Puzzle
• 50934 - Selling Cars
• 50746 - Most Visited
• 50749 - Min Distance
• 50915 - Trip to Korca
• 50985 - Books Waiting
• 50927 - Health Expenses
• 50745 - Bitonic Sequence
• 51083 - Grades Histogram

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Word Puzzle

On a TV program there is word puzzle game. The competitors are given several words and they are given another word whose letters are scrambled. They are asked to find the word in the shortest time. In order not to have any problem in competition time, the program coordinator is asking a program that verifies the words.

Question: You will be given n words and a word whose letters are scrambled, write a program that will find the correct word. If there are several words with the same letters show the first one. The letters may be uppercase or lowercase, it doesn't make any difference. If both words have the same letters they are assumed to be the same and you don't need to count the spaces. You just check if both words have the same letters or not.

Input specification
You will be given one integer in the beginning, the number of words (n) where 1 ≤ n ≤ 1,000. Then in the second line, you will be given target string which is at most 250 characters containing only 26 English letters and spaces. Then, in the following n lines, you will be given n strings.

Output specification
Show the position of the correct word.

Sample Input I
9
ea lCMbtea
Reshat Tarba
Caleb Meta
Olgers Karini
Xhorxho Uka
Xhoxhina Balukja
Kim Cjapi
Elmedin Dosari
Zhaneta Kruja
Alexander Cox
Sample Output I
2


Для отправки решений необходимо выполнить вход.

www.contester.ru