Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* TAHMID RAHMAN
- DAMIAN FOREVER
- MATH LOVER
- NEVER GIVE UP
- */
- #include<bits/stdc++.h>
- using namespace std;
- #define pi acos(-1.0)
- #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
- #define ll long long
- #define pb push_back
- #define fi first
- #define se second
- #define in insert
- #define mp make_pair
- #define GCD(a,b) __gcd(a,b);
- #define endl "\n"
- #define FRU freopen("out.txt","w",stdout)
- #define FRO freopen("in.txt","r",stdin)
- #define INFLL 9223372036854775807
- #define all(x) (x).begin(),(x).end()
- #define debug 0
- #define MAXN 100001
- #define ar array
- #define lb lower_bound
- #define ub upper_bound
- #define minpq priority_queue<ll, vector<ll>, greater<ll>>
- #define maxpq priority_queue<ll>
- const int mxN=2e5;
- const int MOD=1e9+7;
- template<typename ForwardIterator, typename T>
- ForwardIterator first_less_than (ForwardIterator first, ForwardIterator last, T value)
- {auto it = std::lower_bound (first, last, value);
- return (it == first ? last : --it);}
- bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b)
- {
- return (a.second < b.second);
- }
- #define debugxx(v) {for(auto x:v){cout<<x.fi<<" "<<x.se<<endl;}cout<<endl;}
- #define debugx(v){for(auto y:v) {cout<<y<<" ";}cout<<endl;}
- //Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
- ll arr[mxN];
- ll tree[mxN*3];
- void init(ll node,ll b,ll e)
- {
- if(b==e)
- {
- tree[node]=arr[b];
- return ;
- }
- ll left=node*2;
- ll right=node*2+1;
- ll mid=(b+e)/2;
- init(left,b,mid);
- init(right,mid+1,e);
- tree[node]=tree[left]*tree[right];
- }
- ll query(ll node,ll b,ll e,ll i,ll j)
- {
- if(i>e||j<b)
- return 1;
- if(b>=i&&e<=j)
- return tree[node];
- ll left=node*2;
- ll right=node*2+1;
- ll mid=(b+e)/2;
- ll p1=query(left,b,mid,i,j);
- ll p2=query(right,mid+1,e,i,j);
- return p1*p2;
- }
- void update(ll node,ll b,ll e,ll i,ll value)
- {
- if(i>e||i<b)
- return ;
- if(b>=i&&e<=i)
- {
- tree[node]=value;
- return ;
- }
- ll left=node*2;
- ll right=node*2+1;
- ll mid=(b+e)>>1;
- update(left,b,mid,i,value);
- update(right,mid+1,e,i,value);
- tree[node]=tree[left]*tree[right];
- }
- int main()
- {
- ll t;
- ll n,q,i,j,k;
- while(cin>>n)
- {
- cin>>q;
- for(i=1;i<=n;i++)
- {
- ll x;
- cin>>x;
- if(x>0)
- arr[i]=1;
- else if(x<0)
- arr[i]=-1;
- else
- arr[i]=0;
- }
- init(1,1,n);
- string s;
- for(i=0;i<q;i++)
- {
- char c;
- ll l,r;
- cin>>c;
- cin>>l>>r;
- if(c=='C'){
- if(r>0)
- r=1;
- else if(r<0)
- r=-1;
- else
- r=0;
- update(1,1,n,l,r);
- }
- else if(c=='P')
- {
- ll x=query(1,1,n,l,r);
- if(x==0)
- s+='0';
- else if(x>0)
- s+='+';
- else
- s+='-';
- }
- }
- cout<<s<<'\n';
- }
- }
Add Comment
Please, Sign In to add comment