Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define pb push_back
- #define mp make_pair
- #define f first
- #define s second
- #define int long long
- typedef long long ll;
- typedef pair<int,int>pii;
- #define MAXN 1123456
- #define INF INT_MAX/2
- #define MOD 1000000
- int bit[MAXN];
- int bit0[MAXN];
- int v[MAXN];
- void upd(int a){
- for(int i=a;i<MAXN;i+=(i&-i)){
- bit[i]++;
- }
- }
- int get(int a){
- if(a==0)return 0;
- int resp=0;
- for(int i=a;i>0;i-=(i&-i)){
- resp+=bit[i];
- }
- return resp;
- }
- void upd0(int a,int x){
- for(int i=a;i<MAXN;i+=(i&-i)){
- bit0[i]+=x;
- }
- }
- int get0(int a){
- int resp=0;
- for(int i=a;i>0;i-=(i&-i)){
- resp+=bit0[i];
- }
- return resp;
- }
- int32_t main(){
- ios::sync_with_stdio(false);
- cin.tie(0);
- int n,q;
- while(cin>>n){
- cin>>q;
- for(int i=0;i<=n;i++){
- bit[i]=0;
- bit0[i]=0;
- }
- for(int i=1;i<=n;i++){
- int y;
- cin>>y;
- v[i]=y;
- if(y==0)upd0(i,1);
- if(y<0)upd(i);
- }
- for(int i=0;i<q;i++){
- char c;
- cin>>c;
- if(c=='C'){
- int j,x;
- cin>>j>>x;
- if(v[j]<0)upd(j);
- if(v[j]==0)upd0(j,-1);
- v[j]=x;
- if(v[j]<0)upd(j);
- if(v[j]==0)upd0(j,1);
- }
- else{
- int com,fim;
- cin>>com>>fim;
- if(get0(fim)!=get0(com-1))cout<<0;
- else{
- if((get(fim)-get(com-1))%2==0)cout<<"+";
- else cout<<"-";
- }
- }
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement