ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#213195 | #584. t3 | X_X | 0 | 6850ms | 2704kb | C++ | 2.5kb | 2024-11-09 22:53:50 | 2024-11-09 23:30:35 |
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e5+3,T=200,MOD=1e9+7,INF=2e9;
int n,m;
LL a[N];
int l[N],r[N],belong[N];
int turn[N];
LL tag[N],sum[N][20],C[12][12];
void add(LL &x,LL y){
x+=y;
if(x>=MOD) x-=MOD;
if(x<0) x+=MOD;
}
void pre(int x){
for(int i=l[x];i<=r[x];i++){
if(turn[x]!=INF) a[i]=turn[x];
add(a[i],tag[x]);
}
turn[x]=INF,tag[x]=0;
}
void work(int x){
for(int k=0;k<=10;k++) sum[x][k]=0;
for(int i=l[x];i<=r[x];i++){
int mul=1;
for(int k=0;k<=10;k++){
add(sum[x][k],mul);
mul=1ll*mul*a[i]%MOD;
}
}
}
void modify1(int s,int t,int val){
int L=belong[s],R=belong[t];
if(L==R){
pre(L);
for(int i=s;i<=t;i++) add(a[i],val);
work(L);
return;
}
pre(L),pre(R);
for(int i=s;i<=r[L];i++) add(a[i],val);
for(int i=l[R];i<=t;i++) add(a[i],val);
work(L),work(R);
for(int i=L+1;i<=R-1;i++) add(tag[i],val);
}
void modify2(int s,int t,int val){
int L=belong[s],R=belong[t];
pre(L),pre(R);
if(L==R){
pre(L);
for(int i=s;i<=t;i++) a[i]=val;
work(L);
return;
}
for(int i=s;i<=r[L];i++) a[i]=val;
for(int i=l[R];i<=t;i++) a[i]=val;
work(L),work(R);
for(int i=L+1;i<=R-1;i++) turn[i]=val,tag[i]=0;
}
LL Q(int s,int t,int val){
int L=belong[s],R=belong[t];
LL ans=0;
if(L==R){
pre(L);work(L);
for(int i=s;i<=t;i++){
LL mul=1;
for(int j=1;j<=val;j++) mul=mul*a[i]%MOD;
add(ans,mul);
}
return ans;
}
pre(L),pre(R);
work(L),work(R);
for(int i=s;i<=r[L];i++){
LL mul=1;
for(int j=1;j<=val;j++) mul=mul*a[i]%MOD;
add(ans,mul);
}
for(int i=l[R];i<=t;i++){
LL mul=1;
for(int j=1;j<=val;j++) mul=mul*a[i]%MOD;
add(ans,mul);
}
for(int i=L+1;i<=R-1;i++){
LL mul=1;
LL la=ans;
for(int k=0;k<=val;k++){
add(ans,C[val][k]*mul%MOD*sum[i][val-k]%MOD);
mul=mul*tag[i]%MOD;
}
}
return ans;
}
int Main()
{
for(int i=0;i<=10;i++) C[i][0]=1;
for(int i=1;i<=10;i++)
for(int j=1;j<=10;j++)
C[i][j]=C[i-1][j]+C[i-1][j-1];
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) scanf("%d",&a[i]),turn[i]=INF;
int num=n/T+1;
for(int i=1;i<=num;i++){
l[i]=(i-1)*T+1,r[i]=i*T;
for(int j=l[i];j<=r[i];j++)
belong[j]=i;
work(i);
}
while(m--){
int op,l,r,x;
scanf("%d%d%d%d",&op,&l,&r,&x);
if(op==1) modify1(l,r,x);
if(op==2) modify2(l,r,x);
if(op==3) printf("%lld\n",Q(l,r,x));
}
return 0;
}
int main()
{
int Case=1;
while(Case--) Main();
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 21ms
memory: 1232kb
input:
458 823 14431 9895 11970 15308 2575 20181 709 27999 12992 18884 11061 16281 5044 28990 25092 28337 3...
output:
806084096 117884357 581509507 903754571 381316325 789203673 312340523 659242359 741787988 89040104 4...
result:
wrong answer 112th lines differ - expected: '7872426', found: '8463842'
Test #2:
score: 0
Wrong Answer
time: 14ms
memory: 1236kb
input:
481 526 8409 14498 18636 10027 24362 32458 17986 17730 11956 19192 2193 1034 29317 19284 16210 26242...
output:
867105097 717265913 288311190 320452351 133 498037408 473281413 216488030 182572597 611630662 471106...
result:
wrong answer 101st lines differ - expected: '7338474', found: '6910730'
Test #3:
score: 0
Runtime Error
input:
100000 100000 15247 4194 9619 4532 22058 2667 21549 16652 25327 12018 13395 11426 7243 11714 22904 2...
output:
result:
Test #4:
score: 0
Runtime Error
input:
100000 100000 6264 26207 28424 24165 4852 20798 5803 18679 24588 12238 25786 28622 19900 101 25922 2...
output:
result:
Test #5:
score: 0
Runtime Error
input:
100000 100000 15043 9299 7163 25384 24996 3803 24356 12466 22073 12987 8931 14997 3951 32704 23076 8...
output:
result:
Test #6:
score: 0
Runtime Error
input:
100000 100000 14736 16956 19864 23894 29403 5507 12182 6188 17192 14440 18618 3970 15396 15037 23334...
output:
result:
Test #7:
score: 0
Wrong Answer
time: 1693ms
memory: 2052kb
input:
50000 50000 17799 29763 25337 21321 1391 31852 27418 28753 18524 14044 15976 18893 12274 22834 11348...
output:
19498 473297203 816779831 299749756 268995051 256532984 959775666 758730463 888652773 123694131 3904...
result:
wrong answer 3rd lines differ - expected: '695948777', found: '816779831'
Test #8:
score: 0
Wrong Answer
time: 1727ms
memory: 2056kb
input:
50000 50000 10654 14956 14287 25326 8102 30579 11682 23553 272 22672 14460 30241 13026 12738 4912 72...
output:
474518535 185242282 108009962 9940982 158870918 757840097 10388 4939 77525381 675040757 950672495 80...
result:
wrong answer 1st lines differ - expected: '717018991', found: '474518535'
Test #9:
score: 0
Wrong Answer
time: 3395ms
memory: 2704kb
input:
90000 90000 29538 28214 24706 30393 27759 9002 13458 10243 15713 14881 10630 5593 7942 24578 29370 1...
output:
738835738 56894906 3888 479687241 37270 320138292 927930332 852881104 776485620 773884517 172316827 ...
result:
wrong answer 2nd lines differ - expected: '738703020', found: '56894906'
Test #10:
score: 0
Runtime Error
input:
100000 100000 23515 49 31372 25112 16779 21279 30735 32743 14678 15189 1763 23114 32215 14873 20487 ...