Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Language: GHOST
Description GHOST is a spelling game played by bored school kids on long car/bus rides. The purpose of the game it to accumulate letters that spell some word without ever actually finishing a word.Before the game begins, players agree on the order in which they will play. Plays proceed from one player to the next, returning then to the first player until the game is completed. Each player must, in turn, 1) extend the current "word", 2) bluff, or 3) challenge.
Write a program to serve as a player in a game of GHOST. Note that a skillful player will, on her turn, not only worry about coming up with a legal extension to the current sequence of letters, but will also think about all the words that could be formed from an extension and whether, comparing the number of letters in those words to the number of players, consider whether a possible extension could result in her getting stuck on a future turn with no legal extension that does not end a word, thus losing the game. Input The input for this game will consist of a sequence of one or more scenarios.
Each scenario contains the following: The first line of the scenario will contain a single integer indicating the number of players in the game. This value will be at least 2 for a valid scenario. The end of the input file will be indicated by a value less than 2 for this number. Following this will be a list of words to serve as the program's dictionary/vocabulary for the scenario. Each word will appear on a separate line, with no leading, trailing, or internal whitespace. Each word will consist only of the characters {a–z}. The end of this list of words will be signaled by an empty line. Following that empty line, the final input line of the scenario will contain the current sequence of letters, again with no leading or trailing spaces. This sequence may be empty if the computer player is the first player. The sequence may also contain more letters than the number of players, indicating that all players (including the computer player) have taken one or more turns. Output Your program will produce a single line of output for each scenario.
That line of output will consist of the current sequence of letters from the input, followed by a single blank, followed by:
Sample Input 3 area arched apple apply applied ar 2 area arch apple apply applied applying a 2 area ax 0 Sample Output ar e a p ax Challenge Hint 1。如果有必胜的选择,也就是选了某个extension之后,任何以这个extension构成的单词都会导致这个人赢,那肯定先选这种,如果有多个都满足,选最小的那个
2。如果没有上面那种必胜的,那就选可能胜的,也就是以这个extension构成的单词,有的会让他赢,有的会让它输,如果有多种这样的,也选最小的 3。最后如果没有上两种,就只好bluff了 Source |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator