QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#602668 | #8717. 骰子 | UESTC_DECAYALI# | WA | 1647ms | 260812kb | C++20 | 1.6kb | 2024-10-01 11:44:24 | 2024-10-01 11:44:24 |
Judging History
answer
#include<cstdio>
#include<iostream>
#define RI register int
#define CI const int&
using namespace std;
const int N=1505,M=205,mod=1e9+7;
int n,m,q,p[N][M],b[M],f[N][M],ans[N][N],dp[N][M][M];
inline void inc(int& x,CI y)
{
if ((x+=y)>=mod) x-=mod;
}
inline void solve(CI l,CI r)
{
if (l==r)
{
for (RI i=0;i<=m;++i) inc(ans[l][l],1LL*p[l][i]*b[i]%mod);
return;
}
int mid=l+r>>1; solve(l,mid); solve(mid+1,r);
for (RI i=0;i<=m;++i) f[mid][i]=p[mid][i],f[mid+1][i]=p[mid+1][i];
for (RI i=mid-1;i>=l;--i)
{
for (RI j=0;j<=m;++j) f[i][j]=0;
for (RI j=0;j<=m;++j) for (RI k=0;j+k<=m;++j)
inc(f[i][j+k],1LL*f[i+1][j]*p[i][k]%mod);
}
for (RI i=mid+2;i<=r;++i)
{
for (RI j=0;j<=m;++j) f[i][j]=0;
for (RI j=0;j<=m;++j) for (RI k=0;j+k<=m;++j)
inc(f[i][j+k],1LL*f[i-1][j]*p[i][k]%mod);
}
for (RI i=mid+1;i<=r;++i)
{
for (RI j=0;j<=m;++j) for (RI k=0;j+k<=m;++k)
dp[i][j][k]=1LL*f[i][k]*b[j+k]%mod;
for (RI j=0;j<=m;++j) for (RI k=1;j+k<=m;++k)
inc(dp[i][j][k],dp[i][j][k-1]);
}
for (RI i=l;i<=mid;++i) for (RI j=mid+1;j<=r;++j)
for (RI k=0;k<=m;++k) inc(ans[i][j],1LL*f[i][k]*dp[j][k][m-k]%mod);
}
int main()
{
scanf("%d%d%d",&n,&m,&q);
for (RI i=0;i<=m;++i) scanf("%d",&b[i]);
for (RI i=1;i<=n;++i) for (RI j=0;j<=m;++j)
scanf("%d",&p[i][j]),p[i][j]%=mod;
for (solve(1,n);q;--q)
{
int l,r; scanf("%d%d",&l,&r);
printf("%d\n",ans[l][r]);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 10104kb
input:
3 3 3 4 3 2 1 0 1 0 1000000007 0 500000004 0 500000004 0 0 500000004 500000004 1 1 1 2 1 3
output:
3 1 0
result:
ok 3 number(s): "3 1 0"
Test #2:
score: 0
Accepted
time: 1ms
memory: 6028kb
input:
3 3 6 4 3 2 1 1000000007 0 1 0 1000000007 1 0 0 1000000007 0 1 0 1 1 1 2 1 3 2 2 2 3 3 3
output:
2 1 0 3 1 2
result:
ok 6 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 5808kb
input:
1 1 1 604063100 57375033 742299910 257700098 1 1
output:
148903503
result:
ok 1 number(s): "148903503"
Test #4:
score: -100
Wrong Answer
time: 1647ms
memory: 260812kb
input:
1500 200 600000 253665324 876103781 804024983 929290295 908790466 176299158 528078340 696679927 416465140 509641654 705083449 361711737 250659645 735832780 35321360 383752049 203979021 178832532 785212637 514502839 169840231 65809146 504755349 516829442 382478309 901925498 142312128 782336477 741339...
output:
710393608 139773982 873032101 714386471 766927763 506309341 446928263 701124943 178519358 664328133 851636209 475702523 509306979 708002731 28211711 519071023 621096635 914753684 968435360 60112897 460216295 549360624 447963410 819420928 504619388 7115722 122920241 550522746 764352255 882101492 5238...
result:
wrong answer 1st numbers differ - expected: '66394849', found: '710393608'