An Interesting Game

Limits: 6s, 512 MB

Stackmatch is a very popular game of Matland. In this game, they uses C types of coins and a stack. Coins are numbered from 1 to C. In each move, they put a coin(any of the C types) on top of the stack. If the topmost K coins are of the same type, then topmost K coins disappear. All other(If any) coins of the stack remain as they were. The game has an interesting property, before starting the game they fixed the exact number of moves M they will play. To finish the game after M moves the stack must be empty.


This is a companion discussion topic for the original entry at https://toph.co/p/an-interesting-game