#include namespace nono { void naive() { int n, k, t; std::cin >> n >> k >> t; std::vector a(n); std::vector b(n); for (int i = 0; i < n; i++) std::cin >> a[i]; for (int i = 0; i < n; i++) std::cin >> b[i]; std::vector under(n); for (int i = 0; i < n; i++) { if (a[i] == 'B') { under[i] = true; } } std::map, int> mp; mp[b] = 0; for (int i = 0; i < t; i++) { { // 砂移動パート for (int j = 0; j < n; j++) { if (under[j]) { b[j]++; } else { b[j]--; } } } { // ひっくり返しパート for (int j = 0; j < n; j++) { if (b[j] == k) { under[j] = false; } else if (b[j] == 0) { under[j] = true; } } for (int j = 0; j < n; j++) { for (int l = 0; l < n; l++) { if (b[j] == b[l]) { under[j] = (under[j] ? false : true); under[l] = (under[l] ? false : true); } } } } { // 出力パート } if (mp.contains(b)) { std::cerr << "already state!!!" << std::endl; std::cerr << "prev: " << mp[b] << ", new: " << i + 1 << std::endl; } mp[b] = i + 1; } for (int j = 0; j < n; j++) { std::cerr << b[j] << ' '; } std::cerr << std::endl; } void solve() { int n, k, t; std::cin >> n >> k >> t; std::vector a(n); std::vector b(n); for (int i = 0; i < n; i++) std::cin >> a[i]; for (int i = 0; i < n; i++) std::cin >> b[i]; std::vector c(n); t %= 2 * k; for (int i = 0; i < n; i++) { int now = b[i]; bool plus = (a[i] == 'B'); int s = t; while (s > 0) { if (plus) { if (now + s >= k) { s -= k - now; now = k; } else { now += s; s -= s; } } else { if (now <= s) { s -= now; now = 0; } else { now -= s; s -= s; } } plus ^= true; } c[i] = now; } std::ranges::sort(c); std::vector index(n); std::iota(index.begin(), index.end(), 0); std::ranges::sort(index, [&](int lhs, int rhs) { return b[lhs] < b[rhs]; }); std::vector ans(n); for (int i = 0; i < n; i++) { ans[index[i]] = c[i]; } for (int i = 0; i < n; i++) { std::cout << ans[i] << (i + 1 < n ? ' ' : '\n'); } } } // namespace nono int main() { std::cin.tie(0)->sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); int t = 1; while (t--) nono::solve(); }