#include<stdio.h> #include<string.h> int main() { int num = 0; scanf("%d", &num); char arr[100] = ""; scanf("%s", &arr); int b[4] = {0}; for (int i = 0; i < num && i < 4; i++) b[i] = i + 1; int len = strlen(arr); int num1 = 1; //实际光标位置 int numfirst = 0; //窗口第一个在b数组中位置 for (int i = 0; i < len; i++) { if (arr[i] == 'U') { if (num1 == 1 && b[0] == 1 && num >= 4) { num1 = num; b[0] = num - 3; b[1] = num - 2; b[2] = num - 1; b[3] = num; numfirst = 3; } else if (num1 == 1 && b[0] == 1 && num < 4) { num1 = num; numfirst = num - 1; } else if (num1 != 1 && numfirst == 0) { for (int k = 0; k < 4; k++) b[k]--; numfirst = 0; num1--; } else if (num1 != 1 && numfirst != 0) { num1--; numfirst--; } } else if (arr[i] == 'D') { if (num1 == num && b[3] == num && num >= 4) { num1 = 1; b[0] = 1; b[1] = 2; b[2] = 3; b[3] = 4; numfirst = 0; } else if (num1 == num && b[3] == 0 && num < 4) { num1 = 1; numfirst = 0; } else if (num1 != num && numfirst == 3) { for (int k = 0; k < 4; k++) b[k]++; numfirst = 3; num1++; } else if (num1 != num && numfirst != 3) { num1++; numfirst++; } } } for (int i = 0; i < 4 && i < num; i++) printf("%d ", b[i]); printf("\n"); printf("%d", num1); return 0; }