主要用到线段树,涉及到创建,点修改,查询
#include <cstdio>
using namespace std;
const int N = 100010;
int tree[4 * N];
int n, k;
char s[6];
void build(int l, int r, int o)
{
if (l == r) {
int x;
scanf("%d", &x);
if (x < 0) tree[o] = -1;
else if (x == 0) tree[o] = 0;
else tree[o] = 1;
return;
}
int mid = (l + r) >> 1;
build(l, mid, 2 * o);
build(mid + 1, r, 2 * o + 1);
tree[o] = tree[2 * o] * tree[2 * o + 1];
}
void change(int l, int r, int pos, int val, int o)
{
if (l == r) {
if (val < 0) tree[o] = -1;
else if (val == 0) tree[o] = 0;
else tree[o] = 1;
return;
}
int mid = (l + r) >> 1;
if (pos <= mid) change(l, mid, pos, val, 2 * o);
else change(mid + 1, r, pos, val, 2 * o + 1);
tree[o] = tree[2 * o] * tree[2 * o + 1];
}
int query(int l, int r, int a, int b, int o)
{
if (a > r || b < l) return 0;
if (a <= l && b >= r) return tree[o];
int mid = (l + r) >> 1;
if (b <= mid) return query(l, mid, a, b, 2 * o);
if (a > mid) return query(mid + 1, r, a, b, 2 * o + 1);
return query(l, mid, a, b, 2 * o) * query(mid + 1, r, a, b, 2 * o + 1);
}
bool input()
{
if (scanf("%d%d", &n, &k) != 2) return false;
build(1, n, 1);
return true;
}
void solve()
{
for (int i = 0; i < k; i++) {
int a, b;
scanf("%s%d%d", s, &a, &b);
if (s[0] == 'C') {
change(1, n, a, b, 1);
} else {
int res = query(1, n, a, b, 1);
if (res < 0) printf("-");
else if (res == 0) printf("0");
else printf("+");
}
}
printf("\n");
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("d:\\OJ\\uva_in.txt", "r", stdin);
#endif
while (input()) {
solve();
}
return 0;
}