Exemplo n.º 1
0
int main()
{


  int p,c,i,j,k,q,l,t,tt=1,sz;
  string str;
  char ch;
  SegTree tree;
  cin>>t;
  while(t--)
  {
  sz=0;
  cin>>p;
  
  while(p--)
  {
  	cin>>c>>str;
  	l=str.length();
    for(i=0;i<c;i++)
  	for(j=0;j<l;j++)
  	tree.A[sz++]=str[j]-'0';
  }
  tree.n=sz;
  tree.init();
  cin>>q;
  int qnum=0;
  printf("Case %d:\n",tt++);
  while(q--)
  {
   cin>>ch>>i>>j;
   if(ch=='F')tree.set(i,j);
   else if(ch=='E')tree.clear(i,j);
   else if(ch=='I')tree.flip(i,j);
   else printf("Q%d: %d\n",++qnum,tree.query(i,j));
  }
  
  tree.reset();
  }
return  0;	
}
Exemplo n.º 2
0
int main()
{
    Reader rr;

    N = rr.next_u32();
    tree.init(ARRAYSZ);

    char op;
    int i, j, x;
    while (N--) {
        op = rr.next_char();
        i = rr.next_u32();
        j = rr.next_u32();

        switch (op) {
        case 'A':
            tree.inc_left(i, j);
            break;

        case 'B':
            tree.inc_right(i, j);
            break;

        case 'C':
            x = rr.next_int();
            tree.set(i, j, x);
            break;

        case 'S':
            printf("%lld\n", tree.query(i, j));
            break;
        }
    }

    return 0;
}