#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]; t %= 2 * k; std::vector odd, even; 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; } if (b[i] % 2 == 0) { even.push_back(now); } else { odd.push_back(now); } } std::ranges::sort(even); std::ranges::sort(odd); std::vector even_b; std::vector odd_b; for (int i = 0; i < n; i++) { if (b[i] % 2 == 0) { even_b.push_back(b[i]); } else { odd_b.push_back(b[i]); } } std::ranges::sort(even_b); std::ranges::sort(odd_b); std::vector ans(n); for (int i = 0; i < n; i++) { if (b[i] % 2 == 0) { ans[i] = even[std::ranges::lower_bound(even_b, b[i]) - even_b.begin()]; } else { ans[i] = odd[std::ranges::lower_bound(odd_b, b[i]) - odd_b.begin()]; } } 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(); }