Esempio n. 1
0
int main(void) {
	T = in();

	int kind;
	SegmentTree tree;
	
	for ( ; T--; ) {
		N = in();
		C = in();

		tree.clear();
		
		for ( ; C--; ) {
			kind = in();

			if (kind == 0) {
				P = in();
				Q = in();
				V = in();

				tree.update(1, 1, N, P, Q, V);
			} else {
				P = in();
				Q = in();

				printf("%lld\n", tree.query(1, 1, N, P, Q));
			}
		}
	}

	return 0;
}
int main(){
  //Treap::Node* test = Treap::nil;
  //Treap::insert(test, 1);
  //cout << Treap::getRank(test, 2) << endl;
  scanf("%d", &TestNum);
  while (TestNum--){
    scanf("%d", &n);
    int m; scanf("%d", &m);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    SegmentTree::Node root(0, n - 1); 
    tree.init(root);
    while (m--){
      char buf[32]; scanf("%s", buf);
      if (buf[0] == 'Q'){
        int i, j, k; scanf("%d %d %d", &i, &j, &k);
        printf("%d\n", getKth(i - 1, j - 1, k - 1));
      }else{
        int i, t; scanf("%d %d", &i, &t);
        tree.gao(i -1 , i - 1).update(root, a[i - 1], t);
        a[i - 1] = t;
      }
      //printf("new_cnt: %d\n", new_cnt);
    }
    tree.clear(root);
    //printf("new_cnt: %d\n", new_cnt);
    assert(new_cnt == 0);
    //len = 1;
  }
}
Esempio n. 3
0
void expend(int np)
{
	if(str[np] != chr[3]) return;
	int lm = startE(np);
	if(!lm) return;
	printf("ex-lm: %d %d\n", lm, np);
	tree.clear(1,lm,np);
	tree.update(1,np);
}