Loading...
Submission
# When Author Problem Language CPU Memory
20835 2024-06-09 09:16:22 AHAMMED_99 Akash and Cipher C 1 ms 1456 kb Runtime Error - 1
Test Cases
# CPU Memory Points
1 1 ms 1456 kb 0 Runtime Error
2 0 ms 0 kb 0 Skipped
3 0 ms 0 kb 0 Skipped
4 0 ms 0 kb 0 Skipped
5 0 ms 0 kb 0 Skipped
6 0 ms 0 kb 0 Skipped
Source Code
  1. #include <stdio.h>
  2.  
  3. char decrypt_message(int n, char *s, char *q) {
  4. char result[n + 1];
  5. result[n] = '\0';
  6. for (int i = 0; i < n; i++) {
  7. int shift = (q[i] == 'U') ? (i + 1) : -(i + 1);
  8. int char_code = s[i] + shift;
  9. if (char_code < 'a') {
  10. char_code += 26;
  11. } else if (char_code > 'z') {
  12. char_code -= 26;
  13. }
  14. result[i] = char_code;
  15. }
  16. return *result;
  17. }
  18.  
  19. int main() {
  20. int T;
  21. scanf("%d", &T);
  22. for (int t = 0; t < T; t++) {
  23. int n;
  24. scanf("%d", &n);
  25. char s[n + 1], q[n + 1];
  26. scanf("%s", s);
  27. scanf("%s", q);
  28.  
  29. // Decrypt the message and print the result
  30. printf("%s\n", decrypt_message(n, s, q));
  31. }
  32. return 0;
  33. }
  34.