Loading...
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
Test Cases
# CPU Memory Points
1 1 ms 3236 kb 1 Accepted
2 1 ms 3276 kb 1 Accepted
3 1 ms 3288 kb 1 Accepted
4 22 ms 4480 kb 0 Wrong Answer
5 0 ms 0 kb 0 Skipped
6 0 ms 0 kb 0 Skipped
Source Code
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. char shiftUp(char ch, int shift) {
  8. return 'a' + (ch - 'a' + shift) % 26;
  9. }
  10.  
  11. char shiftDown(char ch, int shift) {
  12. return 'a' + (ch - 'a' - shift + 26) % 26;
  13. }
  14.  
  15. void processTestCase(int n, const string& s, const string& q, string& result) {
  16. for (int i = 0; i < n; ++i) {
  17. int shift = i + 1;
  18. if (q[i] == 'U') {
  19. result[i] = shiftUp(s[i], shift);
  20. } else if (q[i] == 'D') {
  21. result[i] = shiftDown(s[i], shift);
  22. }
  23. }
  24. }
  25.  
  26. int main() {
  27. ios::sync_with_stdio(false);
  28. cin.tie(nullptr);
  29.  
  30. int T;
  31. cin >> T;
  32.  
  33. vector<string> results;
  34. results.reserve(T);
  35.  
  36. for (int t = 0; t < T; ++t) {
  37. int n;
  38. cin >> n;
  39. string s, q;
  40. cin >> s >> q;
  41.  
  42. string result(n, ' ');
  43. processTestCase(n, s, q, result);
  44. results.push_back(result);
  45. }
  46.  
  47. for (const auto& result : results) {
  48. cout << result << endl;
  49. }
  50.  
  51. return 0;
  52. }
  53.