Advertisement
Guest User

Untitled

a guest
Sep 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. /*
  6.  
  7. Bismillahir Rahmanir Rahim
  8. Problem :
  9. Problem Link :
  10. Topics :
  11. Solver : Masud Parves
  12. I Love Code More than Sharks Love Blood <3
  13. */
  14.  
  15.  
  16. #define ff first
  17. #define ss second
  18. #define pb push_back
  19. #define mp make_pair
  20. #define all(a) a.begin(), a.end()
  21.  
  22.  
  23. #define sf(a) scanf("%d",&a)
  24. #define sff(a,b) scanf("%d",&a,&b)
  25. #define sfff(a,b,c) scanf("d%d",&a,&b,&c)
  26.  
  27. #define f0(i,b) for(int i=0;i<(b);i++)
  28. #define f1(i,b) for(int i=1;i<=(b);i++)
  29. #define f2(i,a,b) for(int i=(a);i<=(b);i++)
  30. #define fr(i,b,a) for(int i=(b);i>=(a);i--)
  31.  
  32. #define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  33. #define mx 550
  34. #define TEST_CASE(t) for(int z=1 ; z<=t ; z++)
  35. #define PRINT_CASE printf("Case %d:\n",z)
  36. #define NOT_VISITED 0
  37. #define IS_VISITED 1
  38.  
  39.  
  40.  
  41. int fx[4]= {1,-1,0,0};
  42. int fy[4]= {0,0,1,-1};
  43.  
  44.  
  45. const double PI = acos(-1.0);
  46. const double EPS = 1e-6;
  47. const int MOD = (int)1e9+7;
  48. const int maxn = (int)2e5+5;
  49.  
  50. typedef long long ll;
  51. typedef unsigned long long ull;
  52. typedef vector<int> vi;
  53. typedef pair<int, int> pii;
  54. typedef pair<ll, int> plli;
  55. typedef pair<int, ll> pill;
  56.  
  57. int tree[maxn],n;
  58. char str[maxn];
  59.  
  60. void update(int idx, int val)
  61. {
  62. while(idx<=n)
  63. {
  64. tree[idx]+=val;
  65. idx += (idx & (-idx));
  66. }
  67. }
  68.  
  69. int Query(int idx)
  70. {
  71. int sum=0;
  72.  
  73. while(idx>0)
  74. {
  75. sum+=tree[idx];
  76. idx -= (idx & (-idx));
  77. }
  78. return sum;
  79. }
  80. int t,q;
  81. int main()
  82. {
  83. ///freopen("in.txt","r",stdin);
  84. ///freopen("out.txt","w",stdout);
  85. int t;
  86. sf(t);
  87. TEST_CASE(t)
  88. {
  89. memset(tree, 0, sizeof tree);
  90. scanf("%s",&str[1]);
  91. n=strlen(&str[1]);
  92. char ch;
  93. int m;
  94. sf(m);
  95. PRINT_CASE;
  96. while(m--)
  97. {
  98. getchar();
  99. scanf("%c",&ch);
  100.  
  101. if(ch=='I')
  102. {
  103. int a,b;
  104. sff(a,b);
  105. update(a,1);
  106. update(b+1,-1);
  107. }
  108. else
  109. {
  110. int a;
  111. sf(a);
  112. if(Query(a)%2==1)
  113. {
  114. if(str[a]=='0') printf("1\n");
  115. else printf("0\n");
  116. }
  117. else
  118. printf("%c\n",str[a]);
  119. }
  120. }
  121. }
  122. return 0;
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement