ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#211238 | #2398. 游戏 | three_zero30 | 0 | 0ms | 0kb | C++11 | 1.1kb | 2024-08-10 08:44:22 | 2024-08-10 12:33:27 |
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
int op,s,l,r;
const int N=1e6+2;
int sum[4*N],add[4*N];
void Add(int k,int l,int r,int v){
add[k]+=v;
sum[k]+=(r-l+1)*v;
return ;
}
void pushdown(int k,int l,int r){
if(add[k]==0)return ;
int mid=(l+r)>>1;
Add(k*2,l,mid,add[k]);
Add(k*2+1,mid+1,r,add[k]);
add[k]=0;
}
void modify(int k,int l,int r,int x,int y,int v){
if(x<=l && y>=r){
Add(k,l,r,v);
return ;
}
int mid=(l+r)>>1;
pushdown(k,l,r);
if(x<=mid)modify(k*2,l,mid,x,y,v);
if(y>mid)modify(k*2+1,mid+1,r,x,y,v);
sum[k]=sum[k*2]+sum[k*2+1];
}
int check(int k,int l,int r,int x,int y){
if(x<=l && y>=r){
return sum[k];
}
int mid=(l+r)>>1,res=0;
pushdown(k,l,r);
if(x<=mid)res+=check(k*2,l,mid,x,y);
if(y>mid)res+=check(k*2+1,mid+1,r,x,y);
return res;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
while(m--){
cin>>op;
if(op==1){
cin>>s>>l>>r;
for(int i=l;i<=r;i++)modify(1,1,n,i,r,s);
}
else{
cin>>l>>r;
cout<<check(1,1,n,l,r)<<endl;
}
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Time Limit Exceeded
input:
10000 10000 2 7160 9968 1 -473 6964 8476 1 -153 5216 7023 2 6352 6868 1 -323 2338 2855 1 415 8414 88...
output:
0 -110345895 -118168581 -43417983 -565860138 -604843653 1681510163 -534205626 -89290630 484290874 -2...
result:
Test #2:
score: 0
Time Limit Exceeded
input:
10000 10000 1 326 2291 8264 2 2344 3512 1 146 4506 4804 1 342 1373 4495 1 -267 929 3525 1 444 3384 8...
output:
243137972 -1060091578 0 -1569551280 -2143331752 -23729193 -92593716 -1750711324 457417600 -521887992...
result:
Test #3:
score: 0
Time Limit Exceeded
input:
666666 10000 1 92 555251 586462 1 393 28541 523118 1 448 17256 369367 1 -28 89257 596132 1 -338 3136...
output:
result:
Test #4:
score: 0
Time Limit Exceeded
input:
666666 50000 1 -249 309981 333889 1 477 309512 463171 1 0 71655 592642 1 45 191249 527454 1 55 38872...
output:
result:
Test #5:
score: 0
Time Limit Exceeded
input:
666666 100000 1 -183 598736 630118 1 -337 605875 639236 1 -62 265069 340682 1 -96 370300 571646 1 -1...
output:
result:
Test #6:
score: 0
Time Limit Exceeded
input:
666666 100000 2 121929 379928 2 34550 66844 1 96 338911 637923 2 161666 370147 1 -282 313713 463127 ...
output:
0 0 -407132768 -1377190652 6949942 2042225108 1488380744 1524242412 1232831626 -894005658 1721657258
result:
Test #7:
score: 0
Time Limit Exceeded
input:
750000 100000 1 -318 454211 721481 2 239247 294171 2 52513 339575 2 424462 638364 2 683282 740790 1 ...
output:
0 0 -1963942850 378928392 485435788 -1273203470 -1224868594 907125910 -1257477991 191539950 -7719235...
result:
Test #8:
score: 0
Time Limit Exceeded
input:
1000000 100000 1 -108 318728 708230 1 -242 8738 411540 1 -119 458000 972357 2 368015 850304 1 -182 1...
output:
2122125739 1657525224 -685761846
result:
Test #9:
score: 0
Time Limit Exceeded
input:
1000000 100000 2 347033 984386 2 277881 323793 1 431 735974 973576 2 782909 863840 1 -22 379088 6406...
output:
0 0 -714576822 -472972398 813128022 -1307964833 1019234812 -103209202 -649775057 -630083910 -2072294...
result:
Test #10:
score: 0
Time Limit Exceeded
input:
1000000 100000 1 -238 406279 814973 1 -425 637451 721356 1 237 340114 658854 2 279214 591961 2 17862...
output:
-1245564976 2026986341 1904041939 770627349 0 203905136 1548247078 163356817 -868757010 -1325434580 ...