HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Sorting and sequences > problem:


Word Puzzle

Section problems

• 50991 - Intersecting Circles
• 50447 - Swimming Contest - 2
• 50513 - Climbing Up the Stairs
• 50744 - The Smallest Perimeter
• 50743 - Total Scholarships Discount
• 50984 - Top m hardworking employees
• 50847 - The first m trains to leave
• 51002 - The most successful classes
• Word Puzzle
• 50740 - Service Time - 1
• 50750 - Service Time - 2
• 50347 - Selling Oranges
• 50758 - National Elections - Revisited
• 50754 - Team Standings
• 50358 - Series of Odd Numbers
• 50756 - Average of the Nth Student
• 50757 - National Elections - 1

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