ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#213189 | #584. t3 | quliannanyishou | 0 | 5584ms | 70112kb | C++11 | 3.1kb | 2024-11-09 22:32:32 | 2024-11-09 23:29:10 |
answer
#include <bits/stdc++.h>
using namespace std;
int m,n,a[100010],b,c,d,e,o[12][12],jc[12];
long long ans=0;
const int mod=1e9+7;
inline int read()
{
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0' && ch<='9')
x=x*10+ch-'0',ch=getchar();
return x*f;
}
struct hh
{
int lazy1;
int lazy2=-1;
long long val;
}t[11][100010<<2];
long long qp(int x,int y)
{
long long ans=1,temp=x;
while(y)
{
if(y&1)
{
ans=(ans*temp)%mod;
}
y>>=1;
temp=(temp*temp)%mod;
}
return ans;
}
void build(int l,int r,int u)
{
if(l==r)
{
for(int i=0;i<=10;++i)
{
t[i][l].val=qp(a[l],i);
}
return;
}
int mid=(l+r)/2;
build(l,mid,u*2);
build(mid+1,r,u*2+1);
}
void work(int kind,int u,int x)
{
for(int i=1;i<=kind;++i)
{
t[kind][u].val=(t[kind][u].val+((o[kind][i]*qp(x,i))%mod*t[kind-i][u].val)%mod)%mod;
}
}
void pushdown(int u,int l,int r)
{
if(t[1][u].lazy2==-1&&!t[1][u].lazy1)
{
return;
}
for(int i=10;i>=0;--i)
{
if(t[i][u].lazy2!=-1)
{
t[i][u*2].lazy2=t[i][u].lazy2;
t[i][u*2+1].lazy2=t[i][u].lazy2;
t[i][u*2].lazy1=t[i][u].lazy1;
t[i][u*2+1].lazy1=t[i][u].lazy1;
t[i][u*2].val=qp(t[i][u].lazy2,i)*(r-l+1)%mod;
t[i][u*2+1].val=qp(t[i][u].lazy2,i)*(r-l+1)%mod;
work(i,u*2,t[i][u].lazy1);
work(i,u*2+1,t[i][u].lazy1);
}
else
{
t[i][u*2].lazy1+=t[i][u].lazy1;
t[i][u*2+1].lazy1+=t[i][u].lazy1;
work(i,u*2,t[i][u].lazy1);
work(i,u*2+1,t[i][u].lazy1);
}
t[i][u].lazy2=-1;
t[i][u].lazy1=0;
}
}
void change1(int u,int L,int R)
{
if(L>=c&&R<=d)
{
for(int i=10;i>=0;--i)
{
work(i,u,e);
t[i][u].lazy1+=e;
}
return;
}
int mid=(L+R)/2;
if(c<=mid)
{
pushdown(u,L,R);
change1(u*2,L,mid);
}
if(d>=mid+1)
{
pushdown(u,L,R);
change1(u*2+1,mid+1,R);
}
}
void change2(int u,int L,int R)
{
if(L>=c&&R<=d)
{
for(int i=0;i<=10;++i)
{
t[i][u].val=qp(e,i)*(R-L+1)%mod;
t[i][u].lazy2=e;
t[i][u].lazy1=0;
}
return;
}
int mid=(L+R)/2;
if(c<=mid)
{
pushdown(u,L,R);
change2(u*2,L,mid);
}
if(d>=mid+1)
{
pushdown(u,L,R);
change2(u*2+1,mid+1,R);
}
}
void query(int u,int L,int R)
{
if(L>=c&&R<=d)
{
ans=(ans+t[e][u].val)%mod;
return;
}
int mid=(L+R)/2;
if(c<=mid)
{
pushdown(u,L,R);
query(u*2,L,mid);
}
if(d>=mid+1)
{
pushdown(u,L,R);
query(u*2+1,mid+1,R);
}
}
int main()
{
m=read();
n=read();
for(int i=1;i<=m;++i)
{
a[i]=read();
}
jc[0]=o[0][0]=1;
for(int i=1;i<=10;++i)
{
jc[i]=jc[i-1]*i;
}
for(int i=1;i<=10;++i)
{
for(int j=i;j>=0;--j)
{
o[i][j]=jc[i]/jc[j]/jc[i-j];
}
}
build(1,m,1);
for(int i=1;i<=n;++i)
{
b=read();
c=read();
d=read();
e=read();
if(b==1)
{
pushdown(1,1,m);
change1(1,1,m);
}
else if(b==2)
{
pushdown(1,1,m);
change2(1,1,m);
}
else
{
ans=0;
pushdown(1,1,m);
query(1,1,m);
printf("%ld\n",ans);
}
}
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 30ms
memory: 69912kb
input:
458 823 14431 9895 11970 15308 2575 20181 709 27999 12992 18884 11061 16281 5044 28990 25092 28337 3...
output:
149935853 322152638 666037881 598160669 594130392 773564330 812748716 5118937 410530445 962970115 87...
result:
wrong answer 1st lines differ - expected: '806084096', found: '149935853'
Test #2:
score: 0
Wrong Answer
time: 28ms
memory: 69916kb
input:
481 526 8409 14498 18636 10027 24362 32458 17986 17730 11956 19192 2193 1034 29317 19284 16210 26242...
output:
395034757 597511580 999613479 424410861 206 756059678 829672912 641039904 482258057 477272961 704350...
result:
wrong answer 1st lines differ - expected: '867105097', found: '395034757'
Test #3:
score: 0
Time Limit Exceeded
input:
100000 100000 15247 4194 9619 4532 22058 2667 21549 16652 25327 12018 13395 11426 7243 11714 22904 2...
output:
14 537289 293099 187350 482451673 939021347 46959 60091440 38278 730262415 30225 621306958 29967 297...
result:
Test #4:
score: 0
Time Limit Exceeded
input:
100000 100000 6264 26207 28424 24165 4852 20798 5803 18679 24588 12238 25786 28622 19900 101 25922 2...
output:
11 26223345 58434 56396 39182 77744 650513932 19951 944350081 22829 880604621 620549461 6276 1353197...
result:
Test #5:
score: 0
Time Limit Exceeded
input:
100000 100000 15043 9299 7163 25384 24996 3803 24356 12466 22073 12987 8931 14997 3951 32704 23076 8...
output:
11381590 12594 933206664 443895161 331702678 1368 393593018 87282 64062 35271 350444218 2283 51238 5...
result:
Test #6:
score: 0
Time Limit Exceeded
input:
100000 100000 14736 16956 19864 23894 29403 5507 12182 6188 17192 14440 18618 3970 15396 15037 23334...
output:
13 15 248812554 75166631 19830 50466 410994256 69881 27490 54687 196465975 956302676 311478224 63371...
result:
Test #7:
score: 0
Wrong Answer
time: 3126ms
memory: 70112kb
input:
50000 50000 17799 29763 25337 21321 1391 31852 27418 28753 18524 14044 15976 18893 12274 22834 11348...
output:
14 25278997 213843433 366322079 19445703 987645924 838433856 991562889 275593902 734219452 160621095...
result:
wrong answer 1st lines differ - expected: '19498', found: '14'
Test #8:
score: 0
Wrong Answer
time: 2400ms
memory: 70112kb
input:
50000 50000 10654 14956 14287 25326 8102 30579 11682 23553 272 22672 14460 30241 13026 12738 4912 72...
output:
684086701 202264125 501953501 280113407 905389086 394476033 14527 8317 86567305 813871302 609930417 ...
result:
wrong answer 1st lines differ - expected: '717018991', found: '684086701'
Test #9:
score: 0
Time Limit Exceeded
input:
90000 90000 29538 28214 24706 30393 27759 9002 13458 10243 15713 14881 10630 5593 7942 24578 29370 1...
output:
483738535 706264196 7775 415276278 52042 360126347 299610569 352190166 268538845 17856391 182104576 ...
result:
Test #10:
score: 0
Time Limit Exceeded
input:
100000 100000 23515 49 31372 25112 16779 21279 30735 32743 14678 15189 1763 23114 32215 14873 20487 ...
output:
258464859 203302448 957572626 324346197 959721036 582831321 758355490 505655692 710522103 102680969 ...