ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#213138 | #584. t3 | stawalr | 0 | 4066ms | 32716kb | C++ | 3.6kb | 2024-11-09 21:10:03 | 2024-11-09 23:19:00 |
answer
#include<bits/stdc++.h>
#define int long long
#define lc (p<<1)
#define rc (p<<1|1)
#define mid ((s+t)>>1)
using namespace std;
const int mn=1e6+5,mod=1e9+7;
int a[mn];
int n,m;
int b[mn<<2][13];
int lz[mn<<2],lt[mn<<2];
// int tmp[13];
// int dxsqh
void ptg(int p,int c,int type)
{
if(type==1)
{
b[p][10]-=c*((10*b[p][9]+c*((45*b[p][8]+c*((120*b[p][7]+c*((210*b[p][6]+c*((252*b[p][5]+c*((210*b[p][4]+c*((120*b[p][3]+c*((45*b[p][2]+c*((10*b[p][1]+c*b[p][0])%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod;
b[p][9]-=c*((9*b[p][8]+c*((36*b[p][7]+c*((84*b[p][6]+c*((126*b[p][5]+c*((126*b[p][4]+c*((84*b[p][3]+c*((36*b[p][2]+c*((9*b[p][1]+c*b[p][0]%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod;
b[p][8]-=c*((8*b[p][7]+c*((28*b[p][6]+c*((56*b[p][5]+c*((70*b[p][4]+c*((56*b[p][3]+c*((28*b[p][2]+c*((8*b[p][1]+c*b[p][0]%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod;
b[p][7]-=c*((7*b[p][6]+c*((21*b[p][5]+c*((35*b[p][4]+c*((35*b[p][3]+c*((21*b[p][2]+c*((7*b[p][1]+c*b[p][0]%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod;
b[p][6]-=c*((6*b[p][5]+c*((15*b[p][4]+c*((20*b[p][3]+c*((15*b[p][2]+c*((6*b[p][1]+c*b[p][0]%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod;
b[p][5]-=c*((5*b[p][4]+c*((10*b[p][3]+c*((10*b[p][2]+c*((5*b[p][1]+c*b[p][0]%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod;
b[p][4]-=c*((4*b[p][3]+c*((6*b[p][2]+c*((4*b[p][1]+c*b[p][0]%mod)%mod)%mod)%mod)%mod)%mod)%mod;
b[p][3]-=c*((3*b[p][2]+c*((3*b[p][1]+c*b[p][0]%mod)%mod)%mod)%mod)%mod;
b[p][2]-=c*((2*b[p][1]+c*b[p][0]%mod)%mod)%mod;
b[p][1]-=c*b[p][0];
// b[p][0];
b[p][10]=(b[p][10]+mod)%mod;
b[p][9]=(b[p][9]+mod)%mod;
b[p][8]=(b[p][8]+mod)%mod;
b[p][7]=(b[p][7]+mod)%mod;
b[p][6]=(b[p][6]+mod)%mod;
b[p][5]=(b[p][5]+mod)%mod;
b[p][4]=(b[p][4]+mod)%mod;
b[p][3]=(b[p][3]+mod)%mod;
b[p][2]=(b[p][2]+mod)%mod;
b[p][1]=(b[p][1]+mod)%mod;
}
else if(type==2)
{
for(int i=1;i<=10;i++)
{
b[p][i]=(b[p][i-1]*c)%mod;
}
}
if(type==1)
{
lt[p]=max(type,lt[p]);
lz[p]+=c;
}
else if(type==2)
{
lt[p]=2;
lz[p]=c;
}
}
void pup(int p)
{
for(int i=0;i<=10;i++)
{
b[p][i]=(b[lc][i]+b[rc][i])%mod;
}
}
void psd(int p)
{
ptg(lc,lz[p],lt[p]);
ptg(rc,lz[p],lt[p]);
lz[p]=lt[p]=0;
}
void build(int s,int t,int p)
{
if(s==t)
{
b[p][0]=1;
for(int i=1;i<=10;i++)
{
b[p][i]=(b[p][i-1]*a[s])%mod;
}
return;
}
build(s,mid,lc);
build(mid+1,t,rc);
pup(p);
}
void upd(int l,int r,int c,int ct,int s,int t,int p)
{
if(l<=s && t<=r)return ptg(p,c,ct);
psd(p);
if(l<=mid)upd(l,r,c,ct,s,mid,lc);
if(r>mid)upd(l,r,c,ct,mid+1,t,rc);
pup(p);
}
int qry(int l,int r,int x,int s,int t,int p)
{
if(l<=s && t<=r)return b[p][x];
int res=0;
if(l<=mid)res+=qry(l,r,x,s,mid,lc);
if(r>mid)res+=qry(l,r,x,mid+1,t,rc);
res%=mod;
return res;
}
signed main()
{
int op,l,r,x;
scanf("%lld%lld",&n,&m);
for(int i=1;i<=n;i++)
{
scanf("%lld",&a[i]);
}
build(1,n,1);
for(int i=1;i<=m;i++)
{
scanf("%lld%lld%lld%lld",&op,&l,&r,&x);
if(op==1)upd(l,r,x,op,1,n,1);
if(op==2)upd(l,r,x,op,1,n,1);
if(op==3)printf("%lld\n",qry(l,r,x,1,n,1));
}
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 1340kb
input:
458 823 14431 9895 11970 15308 2575 20181 709 27999 12992 18884 11061 16281 5044 28990 25092 28337 3...
output:
806084096 927363956 47627554 691070394 3859564 490202828 145646905 834473835 517486802 466485081 458...
result:
wrong answer 2nd lines differ - expected: '117884357', found: '927363956'
Test #2:
score: 0
Wrong Answer
time: 2ms
memory: 1340kb
input:
481 526 8409 14498 18636 10027 24362 32458 17986 17730 11956 19192 2193 1034 29317 19284 16210 26242...
output:
475077783 717265913 579353455 434283255 133 302988518 798260852 71049105 11929644 426931084 77391412...
result:
wrong answer 1st lines differ - expected: '867105097', found: '475077783'
Test #3:
score: 0
Wrong Answer
time: 544ms
memory: 32716kb
input:
100000 100000 15247 4194 9619 4532 22058 2667 21549 16652 25327 12018 13395 11426 7243 11714 22904 2...
output:
54433 652754655 209836676 82525935 512777402 997478844 38218 22946632 19138 47856265 33559 680970980...
result:
wrong answer 2nd lines differ - expected: '544457741', found: '652754655'
Test #4:
score: 0
Wrong Answer
time: 554ms
memory: 32716kb
input:
100000 100000 6264 26207 28424 24165 4852 20798 5803 18679 24588 12238 25786 28622 19900 101 25922 2...
output:
18923 78065419 41716 34447 32091 80654 374369563 9973 393833145 19797 999846313 193231724 3136 78577...
result:
wrong answer 2nd lines differ - expected: '13111195', found: '78065419'
Test #5:
score: 0
Wrong Answer
time: 542ms
memory: 32716kb
input:
100000 100000 15043 9299 7163 25384 24996 3803 24356 12466 22073 12987 8931 14997 3951 32704 23076 8...
output:
459536237 6296 578946845 876795616 144934509 683 126522588 63953 57030 17635 799008487 5280 57193 29...
result:
wrong answer 1st lines differ - expected: '754347097', found: '459536237'
Test #6:
score: 0
Wrong Answer
time: 598ms
memory: 32716kb
input:
100000 100000 14736 16956 19864 23894 29403 5507 12182 6188 17192 14440 18618 3970 15396 15037 23334...
output:
17008 73008 186176538 17104823 15383 25232 746580348 75334 25854 46510 48556898 966744751 265640911 ...
result:
wrong answer 3rd lines differ - expected: '935797904', found: '186176538'
Test #7:
score: 0
Wrong Answer
time: 377ms
memory: 16964kb
input:
50000 50000 17799 29763 25337 21321 1391 31852 27418 28753 18524 14044 15976 18893 12274 22834 11348...
output:
19498 473297203 308766978 184708638 724130549 864714236 12161874 99511531 292293399 779692315 687810...
result:
wrong answer 3rd lines differ - expected: '695948777', found: '308766978'
Test #8:
score: 0
Wrong Answer
time: 358ms
memory: 16300kb
input:
50000 50000 10654 14956 14287 25326 8102 30579 11682 23553 272 22672 14460 30241 13026 12738 4912 72...
output:
512996425 132958017 477072046 441774327 122782668 61961864 10388 4939 784603826 517026587 92184223 9...
result:
wrong answer 1st lines differ - expected: '717018991', found: '512996425'
Test #9:
score: 0
Wrong Answer
time: 547ms
memory: 32628kb
input:
90000 90000 29538 28214 24706 30393 27759 9002 13458 10243 15713 14881 10630 5593 7942 24578 29370 1...
output:
738835738 818283145 3888 835090994 37270 915326672 23543888 601777068 336470741 725853364 286828692 ...
result:
wrong answer 2nd lines differ - expected: '738703020', found: '818283145'
Test #10:
score: 0
Wrong Answer
time: 542ms
memory: 32716kb
input:
100000 100000 23515 49 31372 25112 16779 21279 30735 32743 14678 15189 1763 23114 32215 14873 20487 ...
output:
576735050 562509678 881641857 504121799 639579695 438534798 879269281 14030812 456667164 456183050 1...
result:
wrong answer 3rd lines differ - expected: '553431297', found: '881641857'