Submission
# | When | Author | Problem | Language | CPU | Memory | |
---|---|---|---|---|---|---|---|
20869 | 2024-06-13 22:12:06 | AHAMMED_99 | Akash and Cipher | C++ 14 | 22 ms | 4480 kb | Wrong Answer - 4 |
Source Code
#include <iostream> #include <vector> #include <string> using namespace std; char shiftUp(char ch, int shift) { return 'a' + (ch - 'a' + shift) % 26; } char shiftDown(char ch, int shift) { return 'a' + (ch - 'a' - shift + 26) % 26; } void processTestCase(int n, const string& s, const string& q, string& result) { for (int i = 0; i < n; ++i) { int shift = i + 1; if (q[i] == 'U') { result[i] = shiftUp(s[i], shift); } else if (q[i] == 'D') { result[i] = shiftDown(s[i], shift); } } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; vector<string> results; results.reserve(T); for (int t = 0; t < T; ++t) { int n; cin >> n; string s, q; cin >> s >> q; string result(n, ' '); processTestCase(n, s, q, result); results.push_back(result); } for (const auto& result : results) { cout << result << endl; } return 0; }