fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <iomanip>
  4. #include <bits/stdc++.h>
  5. #include <cstdio>
  6. #include <string>
  7. #define ll long long
  8. #define ld long double
  9. #define st first
  10. #define nd second
  11. #define pb push_back
  12. #define fin(a,n) for(int i = a; i < n; i++)
  13. #define fjn(a,n) for(int j = a; j < n; j++)
  14. #define all(a) a.begin(),a.end()
  15. #define allr(a) a.rbegin(),a.rend()
  16. #define FAST ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
  17.  
  18. using namespace std;
  19.  
  20. void solve()
  21. {
  22. int n; cin >> n;
  23. string s; cin >> s;
  24. int q, change = 0; cin >> q;
  25. while(q--){
  26. int x, y; cin >> x >> y;
  27. if(x == 1){
  28. change += y;
  29. change %= n;
  30. }
  31. else{
  32. --y; cout << s[(y+change)%n] << '\n';
  33. }
  34. }
  35. }
  36.  
  37. int main()
  38. {
  39. FAST;
  40.  
  41. int tt = 1; cin >> tt;
  42. while (tt--){
  43. solve();
  44. }
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty