- #include <bits/stdc++.h>
- using namespace std;
- #define mx 100005
- int a[mx];
- int n;
- int update(int indx, int v){
- while(indx<=n){
- a[indx]+=v;
- indx+= (indx&(-indx));
- }
- }
- int query(int indx){
- int sum = 0;
- while(indx>0){
- sum+= a[indx];
- indx-=(indx&(-indx));
- }
- return sum;
- }
- int main()
- {
- int ts;
- scanf("%d", &ts);
- for(int p = 1; p <=ts; p++){
- memset(a, 0, sizeof(a));
- printf("Case %d:\n", p);
- char s[mx];
- scanf("%s", s);
- int q;
- n = strlen(s);
- scanf("%d", &q);
- for(int i = 0; i<q ; i++){
- char ch;
- int l, r, p;
- getchar();
- scanf("%c", &ch);
- if(ch=='I'){
- scanf("%d%d", &l, &r);
- update(l, 1);
- update(r+1, -1);
- }
- else if(ch == 'Q'){
- scanf("%d", &p);
- int a = (query(p)%2);
- if(a == 0) printf("%c\n", s[p-1]);
- else {
- if(s[p-1] == '0') printf("1\n");
- else printf("0\n");
- }
- }
- }
- }
- return 0;
- }
Saturday, 29 July 2017
Lightoj 1080 - Binary Simulation
Subscribe to:
Post Comments (Atom)
Most Featured Post
Lightoj 1159 - Batman
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
-
http://lightoj.com/volume_showproblem.php?problem=1382 Problem analysis: This is a rare problem i wrote about so far. After much strugg...
-
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
No comments:
Post a Comment