I solved UVa 978: Lemmings Battle! with a multiset. A multiset has the same underlying implementation as a regular STL set (BST), but it can store multiple copies of the same value, which makes it perfect for modelling these lemmings. Once we know how to utilize the properties of the multiset to help us solve this problem, it’s all about writing out the simulation. One minor implementation detail I will mention here because it tripped me up: It’s important to preserve the state from the beginning of each round until the round is over. For this, I created two vectors gw and bw that kept track of the lemmings which returned from battle. Then after all the battles were finished, I pushed the elements of gw and bw into the green multiset and the blue multiset, respectively.