Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- /*
- Bismillahir Rahmanir Rahim
- Problem :
- Problem Link :
- Topics :
- Solver : Masud Parves
- I Love Code More than Sharks Love Blood <3
- */
- #define ff first
- #define ss second
- #define pb push_back
- #define mp make_pair
- #define all(a) a.begin(), a.end()
- #define sf(a) scanf("%d",&a)
- #define sff(a,b) scanf("%d",&a,&b)
- #define sfff(a,b,c) scanf("d%d",&a,&b,&c)
- #define f0(i,b) for(int i=0;i<(b);i++)
- #define f1(i,b) for(int i=1;i<=(b);i++)
- #define f2(i,a,b) for(int i=(a);i<=(b);i++)
- #define fr(i,b,a) for(int i=(b);i>=(a);i--)
- #define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
- #define mx 550
- #define TEST_CASE(t) for(int z=1 ; z<=t ; z++)
- #define PRINT_CASE printf("Case %d:\n",z)
- #define NOT_VISITED 0
- #define IS_VISITED 1
- int fx[4]= {1,-1,0,0};
- int fy[4]= {0,0,1,-1};
- const double PI = acos(-1.0);
- const double EPS = 1e-6;
- const int MOD = (int)1e9+7;
- const int maxn = (int)2e5+5;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef vector<int> vi;
- typedef pair<int, int> pii;
- typedef pair<ll, int> plli;
- typedef pair<int, ll> pill;
- int tree[maxn],n;
- char str[maxn];
- void update(int idx, int val)
- {
- while(idx<=n)
- {
- tree[idx]+=val;
- idx += (idx & (-idx));
- }
- }
- int Query(int idx)
- {
- int sum=0;
- while(idx>0)
- {
- sum+=tree[idx];
- idx -= (idx & (-idx));
- }
- return sum;
- }
- int t,q;
- int main()
- {
- ///freopen("in.txt","r",stdin);
- ///freopen("out.txt","w",stdout);
- int t;
- sf(t);
- TEST_CASE(t)
- {
- memset(tree, 0, sizeof tree);
- scanf("%s",&str[1]);
- n=strlen(&str[1]);
- char ch;
- int m;
- sf(m);
- PRINT_CASE;
- while(m--)
- {
- getchar();
- scanf("%c",&ch);
- if(ch=='I')
- {
- int a,b;
- sff(a,b);
- update(a,1);
- update(b+1,-1);
- }
- else
- {
- int a;
- sf(a);
- if(Query(a)%2==1)
- {
- if(str[a]=='0') printf("1\n");
- else printf("0\n");
- }
- else
- printf("%c\n",str[a]);
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement