import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNextLine()) { // 注意 while 处理多个 case int n = in.nextInt(); in.nextLine(); String str = in.nextLine(); int[] arr = new int[2]; if (n < 4) { arr[0] = 1; arr[1] = n; }else { arr[0] = 1; arr[1] = 4; } int now = 1;//当前所指向的歌曲序号 for (int i = 0; i < str.length(); i++) { if (str.charAt(i) == 'U') { now--; if (now == 0) { now = n; } } else { now++; if (now == n + 1) { now = 1; } } if (now <= arr[0] && now >= arr[1]) { continue; } else if (now > arr[1]) { arr[1] = now; arr[0] = now - 3; } else if (now < arr[0]) { arr[0] = now; arr[1] = now + 3; } } for (int m = 0; m < arr[1]-arr[0]+1; m++) { System.out.print((arr[0] + m) + " "); } System.out.println(); System.out.println(now); } } }