Advertisement
Guest User

Untitled

a guest
Mar 11th, 2014
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. /*
  2. Awaken
  3. In a web like Hell
  4. How did I reach this place
  5. Why are they haunting me
  6. I cannot look at God's face
  7.  
  8. Paralysing
  9. Brilliant light
  10. Trying to run
  11. Want to scream, but cannot speak
  12. I cannot look at God's face
  13.  
  14. Blind my eyes, I cannot see
  15. What is being done to me
  16. In my mind is only pain
  17. All the memories are drained
  18.  
  19. Victimized
  20. Specimen
  21. Deathless torture
  22. Void with no mercy
  23. Black shroud blinds those who see
  24.  
  25. Violated
  26. Naked before you I stand
  27. Shattered shrine of flesh and bone
  28. God's piercing through my soul
  29.  
  30. Segments of my life
  31. Morbid pieces of reality
  32. Twisted personality
  33. Many faces yet faceless
  34. Familiar things give way to strange
  35. No mercy no reason just pain
  36.  
  37. Fatal
  38. Sub-conscious control
  39. Threshhold of pain unfolds
  40. Transfixed martyr saving race
  41. Who am I to judge thy grace
  42.  
  43. Awaken
  44. In a web like Hell
  45. How did I reach this place
  46. Why are they haunting me
  47. I cannot look at God's face
  48.  
  49. Blind my eyes, I cannot see
  50. What is being done to me
  51. In my mind is only pain
  52. All the memories are drained
  53. */
  54.  
  55. //#pragma comment(linker, "/STACK:16777216")
  56. #include <fstream>
  57. #include <iostream>
  58. #include <string>
  59. #include <complex>
  60. #include <math.h>
  61. #include <set>
  62. #include <vector>
  63. #include <map>
  64. #include <queue>
  65. #include <stdio.h>
  66. #include <stack>
  67. #include <algorithm>
  68. #include <list>
  69. #include <memory.h>
  70.  
  71. #define y0 sdkfaslhagaklsldk
  72. #define y1 aasdfasdfasdf
  73. #define yn askfhwqriuperikldjk
  74. #define j1 assdgsdgasghsf
  75. #define tm sdfjahlfasfh
  76. #define lr asgasgash
  77.  
  78. #define INF 100000000
  79. #define eps 1e-8
  80. //#define M_PI 3.141592653589793
  81. //#define mx 1000000000000ll
  82. #define bs 1000000007
  83.  
  84. //#define free asdfasdfsdadsg
  85. //#define szz 400
  86. //#define pb push_back
  87. #define MAXN 10000
  88. #define free afdshjioey
  89. //#define SIZE 60
  90. #define bsize 256
  91. #define clone agsdahfaassdg
  92.  
  93. using namespace std;
  94.  
  95. long n,quer,l,r,val;
  96.  
  97. string st;
  98. long long ar1[200000];long ar[200000],nupd[200000],ar2[200000];
  99.  
  100. long long gett(long l,long r)
  101. {
  102. if (nupd[l/bsize])
  103. {
  104. nupd[l/bsize]=0;
  105. for (int i=l/bsize*bsize;i<l/bsize*bsize+bsize;i++)
  106. {
  107. ar[i]=ar2[i/bsize];
  108. }
  109. }
  110. if (nupd[r/bsize])
  111. {
  112. nupd[r/bsize]=0;
  113. for (int i=r/bsize*bsize;i<r/bsize*bsize+bsize;i++)
  114. {
  115. ar[i]=ar2[i/bsize];
  116. }
  117. }
  118.  
  119. long long res=0;
  120. while (l<=r&&l%bsize!=0)
  121. {
  122. res+=ar[l];++l;
  123. }
  124. while (l+bsize<=r)
  125. {
  126. res+=ar1[l/bsize];l+=bsize;
  127. }
  128. while (l<=r)
  129. {
  130. res+=ar[l];++l;
  131. }
  132. return res;
  133. }
  134.  
  135. void update(long l,long r,long val)
  136. {
  137. if (nupd[l/bsize])
  138. {
  139. nupd[l/bsize]=0;
  140. for (int i=l/bsize*bsize;i<l/bsize*bsize+bsize;i++)
  141. {
  142. ar[i]=ar2[i/bsize];
  143. }
  144. }
  145. if (nupd[r/bsize])
  146. {
  147. nupd[r/bsize]=0;
  148. for (int i=r/bsize*bsize;i<r/bsize*bsize+bsize;i++)
  149. {
  150. ar[i]=ar2[i/bsize];
  151. }
  152. }
  153.  
  154. while (l<=r&&l%bsize!=0)
  155. {
  156. ar1[l/bsize]-=ar[l];
  157. ar1[l/bsize]+=val;
  158. ar[l]=val;++l;
  159. }
  160.  
  161. while (l+bsize<=r)
  162. {
  163. ar2[l/bsize]=val;
  164. ar1[l/bsize]=1ll*val*bsize;
  165. nupd[l/bsize]=1;
  166. l+=bsize;
  167. }
  168. while (l<=r)
  169. {
  170. ar1[l/bsize]-=ar[l];
  171. ar1[l/bsize]+=val;
  172. ar[l]=val;++l;
  173. }
  174. }
  175.  
  176. int main(){
  177. freopen("sum.in","r",stdin);
  178. freopen("sum.out","w",stdout);
  179. //freopen("C:/input.txt","r",stdin);
  180. //freopen("C:/output.txt","w",stdout);
  181. ios_base::sync_with_stdio(0);
  182.  
  183. cin>>n>>quer;
  184. for (int i=1;i<=quer;i++)
  185. {
  186. cin>>st;
  187. if (st=="Q")
  188. {
  189. cin>>l>>r;
  190. cout<<gett(l,r)<<endl;
  191. }
  192. else
  193. {
  194. cin>>l>>r>>val;
  195. update(l,r,val);
  196. }
  197. }
  198.  
  199. cin.get();cin.get();
  200. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement