QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#614137 | #9436. Some Sum of Subset | ucup-team5075# | WA | 157ms | 208604kb | C++14 | 1.6kb | 2024-10-05 15:41:21 | 2024-10-05 15:41:23 |
Judging History
answer
#include<iostream>
#include<cstdio>
using namespace std;
#define int long long
const int N=3009,mod=998244353;
int dp[2][N][N],ans[N];
int sum[N][N];
int C[N][N],Csum[N][N],cf[N];
int cnt[N],cnts[N];
int n,m,a[N];
void Add(int &x,int y){x+=y;if(x>=mod) x-=mod;}
signed main()
{
scanf("%lld%lld",&n,&m);
for(int i=1;i<=n;i++) scanf("%lld",&a[i]),cnt[a[i]]++;
for(int i=0;i<=3000;i++)
{
C[i][0]=Csum[i][0]=1;
for(int j=1;j<=i;j++)
(C[i][j]=C[i-1][j]+C[i-1][j-1])%mod;
for(int j=1;j<=n;j++) Csum[i][j]=(Csum[i][j-1]+C[i][j])%mod;
}
cf[0]=1;
for(int i=1;i<=3000;i++) cf[i]=cf[i-1]*2%mod;
for(int i=1;i<=3000;i++) cnts[i]=cnts[i-1]+cnt[i];
dp[1][0][0]=1;
for(int i=3000;i>=1;i--)
{
for(int j=0;(i+1)*j<=m;j++)
for(int k=m-1;k>=0;k--)
sum[j][k]=(sum[j][k+1]+dp[(i+1)&1][j][k])%mod;
if(i<m)
{
for(int j=0;(i+1)*j<m;j++)
for(int l=1;i*l<m&&l<=cnt[i];l++)
{
for(int d=l;d<=cnt[i];d++)
for(int kk=0;kk<=cnts[i]-d;kk++)
Add(ans[kk],(sum[j][m-i*l]-sum[j][m-i*(l-1)]+mod)
*C[d-1][l-1]%mod
*(Csum[cnts[i]-d][cnts[i]-d]-Csum[cnts[i]-d][kk]+C[cnts[i]-d][kk]+mod)%mod);
}
}
for(int j=0;i*j<m;j++)
for(int k=0;k<m;k++)
for(int l=0;l<=j&&l<=cnt[i]&&l*i<=k;l++)
Add(dp[i&1][j][k],dp[(i+1)&1][j-l][k-l*i]);
for(int j=0;(i+1)*j<m;j++)
for(int k=0;k<m;k++)
dp[(i+1)&1][j][k]=0;
// cerr<<i<<" : \n";
// for(int i=0;i<=n;i++) printf("%lld ",ans[i]);
// puts("");
}
for(int i=0;i<=n;i++) (ans[i]+=(Csum[n][n]-Csum[n][i])-(Csum[cnts[m-1]][cnts[m-1]]-Csum[cnts[m-1]][i])+mod*3)%=mod;
for(int i=0;i<=n;i++) printf("%lld\n",ans[i]);
}
详细
Test #1:
score: 100
Accepted
time: 8ms
memory: 149416kb
input:
4 7 3 1 5 2
output:
6 4 1 0 0
result:
ok 5 tokens
Test #2:
score: 0
Accepted
time: 0ms
memory: 147516kb
input:
1 5 7
output:
1 0
result:
ok 2 tokens
Test #3:
score: 0
Accepted
time: 7ms
memory: 147356kb
input:
9 18 1 9 5 6 2 7 1 4 8
output:
346 309 230 126 46 10 1 0 0 0
result:
ok 10 tokens
Test #4:
score: 0
Accepted
time: 89ms
memory: 191876kb
input:
1 1467 556
output:
0 0
result:
ok 2 tokens
Test #5:
score: 0
Accepted
time: 131ms
memory: 208604kb
input:
1 1753 2514
output:
1 0
result:
ok 2 tokens
Test #6:
score: 0
Accepted
time: 76ms
memory: 177036kb
input:
1 1182 1182
output:
1 0
result:
ok 2 tokens
Test #7:
score: 0
Accepted
time: 157ms
memory: 207644kb
input:
2 1741 955 835
output:
1 0 0
result:
ok 3 tokens
Test #8:
score: 0
Accepted
time: 111ms
memory: 193180kb
input:
2 1481 2004 1570
output:
3 1 0
result:
ok 3 tokens
Test #9:
score: 0
Accepted
time: 109ms
memory: 184832kb
input:
2 1336 1336 1336
output:
3 1 0
result:
ok 3 tokens
Test #10:
score: 0
Accepted
time: 14ms
memory: 152900kb
input:
12 400 2163 2729 1322 2787 2404 1068 1502 746 898 2057 1771 502
output:
4095 4083 4017 3797 3302 2510 1586 794 299 79 13 1 0
result:
ok 13 tokens
Test #11:
score: 0
Accepted
time: 136ms
memory: 199772kb
input:
42 1609 532 722 2650 2889 2260 659 1831 401 2779 1262 2185 1479 515 552 1627 637 1080 580 1589 2154 2650 219 2924 1712 311 2609 1062 968 1357 1310 1942 2419 2465 300 2546 2537 2967 1197 2271 1551 999 2531
output:
780135870 780135476 780133126 780115746 779984839 779086101 773744618 746617208 628409426 182368401 707355349 419830171 342550392 778349940 825220795 979080057 177969332 68371210 748001250 187917550 492152134 287983982 592218358 32133349 711757614 602140473 799225822 952989153 1466429 437088327 3596...
result:
ok 43 tokens
Test #12:
score: -100
Wrong Answer
time: 4ms
memory: 147348kb
input:
93 24 1687 2324 1216 2696 2884 1678 1301 1957 1247 526 2519 2252 2141 960 1505 175 315 388 440 892 837 1942 256 1667 641 1629 2565 2837 1200 2427 418 1072 427 1589 969 886 2991 2249 539 1132 949 2425 2616 2107 1259 582 1979 386 177 1860 2825 316 2004 956 1218 2332 1498 2939 1126 1706 404 1604 505 11...
output:
529539543 529539450 529535172 529405406 526485671 474514388 710513257 221089990 200572723 672294770 42835941 919751130 423416627 555968018 315160185 311348445 791888389 208599630 851473968 314557060 217473756 317013642 788174546 121456201 245058214 742842552 667647289 976992539 175318041 374765365 4...
result:
wrong answer 1st words differ - expected: '958346177', found: '529539543'