Pirate game solution for n pirates in C++