Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Awaken
- In a web like Hell
- How did I reach this place
- Why are they haunting me
- I cannot look at God's face
- Paralysing
- Brilliant light
- Trying to run
- Want to scream, but cannot speak
- I cannot look at God's face
- Blind my eyes, I cannot see
- What is being done to me
- In my mind is only pain
- All the memories are drained
- Victimized
- Specimen
- Deathless torture
- Void with no mercy
- Black shroud blinds those who see
- Violated
- Naked before you I stand
- Shattered shrine of flesh and bone
- God's piercing through my soul
- Segments of my life
- Morbid pieces of reality
- Twisted personality
- Many faces yet faceless
- Familiar things give way to strange
- No mercy no reason just pain
- Fatal
- Sub-conscious control
- Threshhold of pain unfolds
- Transfixed martyr saving race
- Who am I to judge thy grace
- Awaken
- In a web like Hell
- How did I reach this place
- Why are they haunting me
- I cannot look at God's face
- Blind my eyes, I cannot see
- What is being done to me
- In my mind is only pain
- All the memories are drained
- */
- //#pragma comment(linker, "/STACK:16777216")
- #include <fstream>
- #include <iostream>
- #include <string>
- #include <complex>
- #include <math.h>
- #include <set>
- #include <vector>
- #include <map>
- #include <queue>
- #include <stdio.h>
- #include <stack>
- #include <algorithm>
- #include <list>
- #include <memory.h>
- #define y0 sdkfaslhagaklsldk
- #define y1 aasdfasdfasdf
- #define yn askfhwqriuperikldjk
- #define j1 assdgsdgasghsf
- #define tm sdfjahlfasfh
- #define lr asgasgash
- #define INF 100000000
- #define eps 1e-8
- //#define M_PI 3.141592653589793
- //#define mx 1000000000000ll
- #define bs 1000000007
- //#define free asdfasdfsdadsg
- //#define szz 400
- //#define pb push_back
- #define MAXN 10000
- #define free afdshjioey
- //#define SIZE 60
- #define bsize 256
- #define clone agsdahfaassdg
- using namespace std;
- long n,quer,l,r,val;
- string st;
- long long ar1[200000];long ar[200000],nupd[200000],ar2[200000];
- long long gett(long l,long r)
- {
- if (nupd[l/bsize])
- {
- nupd[l/bsize]=0;
- for (int i=l/bsize*bsize;i<l/bsize*bsize+bsize;i++)
- {
- ar[i]=ar2[i/bsize];
- }
- }
- if (nupd[r/bsize])
- {
- nupd[r/bsize]=0;
- for (int i=r/bsize*bsize;i<r/bsize*bsize+bsize;i++)
- {
- ar[i]=ar2[i/bsize];
- }
- }
- long long res=0;
- while (l<=r&&l%bsize!=0)
- {
- res+=ar[l];++l;
- }
- while (l+bsize<=r)
- {
- res+=ar1[l/bsize];l+=bsize;
- }
- while (l<=r)
- {
- res+=ar[l];++l;
- }
- return res;
- }
- void update(long l,long r,long val)
- {
- if (nupd[l/bsize])
- {
- nupd[l/bsize]=0;
- for (int i=l/bsize*bsize;i<l/bsize*bsize+bsize;i++)
- {
- ar[i]=ar2[i/bsize];
- }
- }
- if (nupd[r/bsize])
- {
- nupd[r/bsize]=0;
- for (int i=r/bsize*bsize;i<r/bsize*bsize+bsize;i++)
- {
- ar[i]=ar2[i/bsize];
- }
- }
- while (l<=r&&l%bsize!=0)
- {
- ar1[l/bsize]-=ar[l];
- ar1[l/bsize]+=val;
- ar[l]=val;++l;
- }
- while (l+bsize<=r)
- {
- ar2[l/bsize]=val;
- ar1[l/bsize]=1ll*val*bsize;
- nupd[l/bsize]=1;
- l+=bsize;
- }
- while (l<=r)
- {
- ar1[l/bsize]-=ar[l];
- ar1[l/bsize]+=val;
- ar[l]=val;++l;
- }
- }
- int main(){
- freopen("sum.in","r",stdin);
- freopen("sum.out","w",stdout);
- //freopen("C:/input.txt","r",stdin);
- //freopen("C:/output.txt","w",stdout);
- ios_base::sync_with_stdio(0);
- cin>>n>>quer;
- for (int i=1;i<=quer;i++)
- {
- cin>>st;
- if (st=="Q")
- {
- cin>>l>>r;
- cout<<gett(l,r)<<endl;
- }
- else
- {
- cin>>l>>r>>val;
- update(l,r,val);
- }
- }
- cin.get();cin.get();
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement