Submission
# | When | Author | Problem | Language | CPU | Memory | |
---|---|---|---|---|---|---|---|
20868 | 2024-06-13 22:06:36 | AHAMMED_99 | Akash and Cipher | C++ 14 | 22 ms | 4568 kb | Wrong Answer - 4 |
Source Code
#include <iostream> #include <string> #include <vector> using namespace std; char shift_char_up(char ch, int shift) { return 'a' + (ch - 'a' + shift) % 26; } char shift_char_down(char ch, int shift) { return 'a' + (ch - 'a' - shift + 26) % 26; } void decrypt_message(int n, const string& s, const string& q, string& result) { for (int i = 0; i < n; ++i) { if (q[i] == 'U') { result[i] = shift_char_up(s[i], i + 1); } else if (q[i] == 'D') { result[i] = shift_char_down(s[i], i + 1); } } } 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, ' '); decrypt_message(n, s, q, result); results.push_back(result); } for (const auto& result : results) { cout << result << endl; } return 0; }