fork download
  1. #pragma warning(disable:4786)
  2. #pragma warning(disable:4996)
  3. #include<bits/stdc++.h>
  4. #include <ext/pb_ds/assoc_container.hpp>
  5. #include <ext/pb_ds/trie_policy.hpp>
  6. #include<ext/pb_ds/detail/standard_policies.hpp>
  7. #include <ext/rope>
  8. #define pii pair<int,int>
  9. #define pll pair<long long ,long long>
  10. #define pli pair<long long , int>
  11. #define pil pair<int ,long long>
  12. #define pi acos(-1)
  13. #define pb push_back
  14. #define mkp make_pair
  15. #define all(a) a.begin(), a.end()
  16. #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  17. #define ll long long
  18. #define MAX 300005
  19. #define INF 0x3f3f3f3f
  20. template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
  21. template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);} // M is prime}
  22.  
  23. using namespace std;
  24. using namespace __gnu_pbds;
  25. using namespace __gnu_cxx;
  26.  
  27. typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
  28. typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
  29. typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
  30.  
  31.  
  32.  
  33.  
  34. int main(){
  35. IOS
  36. //freopen("output.txt","w",stdout);
  37. string s;
  38. cin>>s;
  39.  
  40. rope<char>rop;
  41.  
  42. for(int i=0;i<s.length();i++){
  43. rop.pb(s[i]);
  44. }
  45. int q;
  46. cin>>q;
  47.  
  48. for(int tt=0;tt<q;tt++){
  49.  
  50. int type;
  51. cin>>type;
  52. if(type==1){
  53. int x,y;
  54. cin>>x>>y;
  55. if(x>y)swap(x,y);
  56. if(x==0 && y==s.length()-1)continue;
  57. auto temp = rop.substr(x,y-x+1);
  58. rop.erase(x,y-x+1);
  59. reverse(temp.mutable_begin(),temp.mutable_end());
  60. rop.insert(rop.mutable_begin(),temp);
  61. }
  62. else if(type==2){
  63. int x,y;
  64. cin>>x>>y;
  65. if(x>y)swap(x,y);
  66. if(x==0 && y==s.length()-1)continue;
  67. auto temp = rop.substr(x,y-x+1);
  68. rop.erase(x,y-x+1);
  69. reverse(temp.mutable_begin(),temp.mutable_end());
  70. rop.insert(rop.mutable_end(),temp);
  71. }
  72. else{
  73. int y;
  74. cin>>y;
  75. cout<<rop[y]<<"\n";
  76. }
  77. }
  78. }
  79.  
Success #stdin #stdout 0s 4512KB
stdin
Standard input is empty
stdout
Standard output is empty