Public submissions
Source code of every submission to this problem in this contest will be visible for everyone since 2013-03-14 06:00:00.
Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

HMN - Hangman

Hangman

You are playing a game of Hangman with your brother. He begins by choosing a word, and he writes down one blank for each letter in the word. You then repeatedly guess letters that you think could be in the word. Every time you guess a letter, your brother indicates every occurrence of that letter in the word by replacing blanks with the corresponding letter. For example, suppose your brother chooses the word, "NINJA".

He begins by writing down 5 blanks, indicated here by dashes: "-----". Suppose you first guess the letter 'A'. Then, your brother would reveal the one instance of 'A' in the word: "----A". Suppose you next guess the letter 'N'. Then, your brother would reveal both instances of 'N' in the word: "N-N-A". Suppose you next guess the letter 'E'. Then, your brother would reveal nothing new since 'E' is not in the word: "N-N-A".

You will be given a String feedback and a sequence of words. Since your brother is fairly predictable, you have determined that the word he is thinking of is an element of words. You also have the information he has given you after some number of guesses (possibly 0), given in feedback. As above, blanks are represented by dashes ('-'), and revealed letters are represented by capital letters ('A'-'Z'). You now wish to guess the word that your brother is thinking of. If there is exactly one element of words that is consistent with feedback, you should print that element. Otherwise, you should print an empty line.

 

 

You are playing a game of Hangman with your brother. He begins by choosing a word, and he writes down one blank

 

for each letter in the word. You then repeatedly guess letters that you think could be in the word. Every time you guess
a letter, your brother indicates every occurrence of that letter in the word by replacing blanks with the corresponding
letter. For example, suppose your brother chooses the word, "NINJA".
He begins by writing down 5 blanks, indicated here by dashes: "-----".
Suppose you first guess the letter 'A'. Then, your brother would reveal the one instance of 'A' in the word: "----A".
Suppose you next guess the letter 'N'. Then, your brother would reveal both instances of 'N' in the word: "N-N-A".
Suppose you next guess the letter 'E'. Then, your brother would reveal nothing new since 'E' is not in the word: "N-NA".
You will be given a String feedback and a sequence of words. Since your brother is fairly predictable, you have
determined that the word he is thinking of is an element of words. You also have the information he has given you after
some number of guesses (possibly 0), given in feedback. As above, blanks are represented by dashes ('-'), and revealed
letters are represented by capital letters ('A'-'Z'). You now wish to guess the word that your brother is thinking of. If
there is exactly one element of words that is consistent with feedback, you should print that element. Otherwise, you
should print an empty line.

Notes:

feedback will contain between 1 and 50 characters inclusive.

Each character in feedback will be either a capital letter ('A'-'Z') or a dash ('-').

words will contain between 1 and 50 elements inclusive.

Each element in words will contain between 1 and 50 characters inclusive.

No two elements in words will be equal.

Each character in each element of words will be a capital letter ('A'-'Z').

 

 

 

Input Specification

The input will contain several test cases, each test cases will be in two lines, a line with the feedback, and another with the given words.

Output Specification

Print one line per test case with the answer, follow the format below

 

 

 

Input Example

N-N-A

NINJA NINJAS FLIPS OUT FRISBEE

B--B--

BRINGS BARBED BUBBLE

---------

MONKEY FORCE IS GAINING STRENGTH

-AAA--

CAAABB BAAACC

 

Output Example

NINJA

BARBED

 

 

You can find the statement here


Added by:Fabio Avellaneda
Date:2013-02-25
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C C++ 4.3.2 CPP JAVA
Public source code since: 2013-03-14 06:00:00

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.