/* -*- coding: utf-8 -*- * * 1021.cc: No.1021 Children in Classrooms - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; const int MAX_M = 200000; /* typedef */ typedef long long ll; typedef vector vi; typedef queue qi; typedef pair pii; /* global variables */ int as[MAX_N]; char s[MAX_M + 4]; /* subroutines */ /* main */ int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", as + i); scanf("%s", s); int cl = 0, cr = n - 1; for (int i = 0; i < m ; i++) { if (s[i] == 'L') { int nl = (cl + 1) % n, nr = (cr + 1) % n; as[nl] += as[cl]; as[cl] = 0; cl = nl, cr = nr; } else { int nl = (cl + n - 1) % n, nr = (cr + n - 1) % n; as[nr] += as[cr]; as[cr] = 0; cl = nl, cr = nr; } } for (int i = 0; i < n; i++) { if (i) putchar(' '); printf("%d", as[(cl + i) % n]); } putchar('\n'); return 0; }