/* Solution to LCR */ import java.util.*; public class LCR { public static Scanner in; public static int caseNum; public static int n; // number of players public static int player[]; // number of chips held by each player public static String rolls; // dice rolls public static void main(String[] args) { in = new Scanner(System.in); caseNum = 0; while ((n = in.nextInt()) != 0) { caseNum++; rolls = in.next(); player = new int[n]; for (int i = 0; i < n; i++) player[i] = 3; int current = 0; // current player int pos = 0; // current position in "rolls" int hasChips = n; int center = 0; while (true) { // See if game over (only one player has any chips): if (hasChips == 1) break; // See if no more rolls left: if (pos >= rolls.length()) break; // See if this player has any chips (if not, skip): if (player[current] == 0) { current = (current+1)%n; continue; } int k = Math.min(3,player[current]); if (pos+k-1 >= rolls.length()) break; for (int i = 0; i < k; i++) { char r = rolls.charAt(pos+i); if (r == 'R') { player[current]--; if (player[(current-1+n)%n] == 0) { // this player is no longer out of chips... hasChips++; } player[(current-1+n)%n]++; } else if (r == 'L') { player[current]--; if (player[(current+1)%n] == 0) { // this player is no longer out of chips... hasChips++; } player[(current+1)%n]++; } else if (r == 'C') { player[current]--; center++; } // Now see if current player is out of chips: if (player[current] == 0) hasChips--; } pos = pos+k; // Advance to next player: current = (current+1)%n; } // Game over; print information: if (caseNum > 1) System.out.println(); // Extra loop to determine (*) placement, if needed: int starLoc = current; if (hasChips > 1) { for (int i = 0; i < n; i++) { int j = (i+current)%n; if (player[j] > 0) { starLoc = j; break; } } } System.out.println("Game "+caseNum + ":"); for (int i = 0; i < n; i++) { System.out.print("Player " + (i+1)+":"+player[i]); if (hasChips==1 && player[i] > 0) System.out.print("(W)"); else if (hasChips > 1 && i == starLoc) System.out.print("(*)"); System.out.println(); } System.out.println("Center:"+center); } } }