
2005 South Central USA Regional Programming Contest 


Results
Final Standings Problem Set Contest Home UTA Site Schedule Information FAQ LSU Site Schedule Information Details FAQ Environment Contest Details Welcome Rules Hints Compile Howto PC^2 About PC^2 Documentation Local Mirror Next Year ACM Intl Prog Contest South Central US Regional Registration 
Introduction: Peg games may be played on a variety of boards, but the goal is always the same, to end the game with as few pegs on the board as possible. This is accomplished by making a sequence of moves, where one peg 'jumps' an adjacent peg to the empty space on the opposite side. Pegs which are jumped by other pegs are immediately removed. Given the starting configuration of a peg board, your program should determine the number of pegs that will remain on the board if the player makes the best possible sequence of moves. One standard peg board is a 5x5 cross (shown below with periods indicating empty peg holes and pound signs indicating nonplayable space). Figure A shows an empty board. Figure B shows a board with five pegs, indicated by lowercase letter os. and Figure C shows the result of an optimal sequence of moves from Figure B's starting position. Note that this ends with 1 peg, the best possible result for any game. Also note that the optimal sequence of moves used to generate Figure C is not unique; there are at least two sets of moves that leave only one peg.
Note that not all of the peg boards given to you will be the same shape! They will all be 5x5, and will all have at least one peg, at least one empty cell, and at least four nonplayable spaces, but the layout may differ drastically from the above. Input: Input to this problem will begin with a line containing a single integer n indicating the number of boards that require analysis. The following 5n lines contain the boards. Each board has a representation like that in the figure above, with a period (.) representing an empty space, lower case o representing a peg, and # representing a nonplayable space. Output: For each board in the input, print the message "The best case ends with Y pegs." where Y is replaced with the number of pegs remaining after an optimal set of jumps. Sample Input: 3 #.o.# ..o.. oo.o. ..... #...# #...# o.o.o ....o ...o. #o..# #..## .o..# ooo.o .o.o. #..o# Sample Output: The best case ends with 1 pegs. The best case ends with 4 pegs. The best case ends with 2 pegs.

[Printable]
LSU Home Search Campus Map ACM Chapter CCT Computing Services Computer Science Our Contests 2005 2004 2003 2002 2001 2000 Index 