QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#662870#1284. Partition Numbership2077WA 213ms6212kbC++23911b2024-10-21 11:30:092024-10-21 11:30:09

Judging History

你现在查看的是最新测评结果

  • [2024-10-21 11:30:09]
  • 评测
  • 测评结果:WA
  • 用时:213ms
  • 内存:6212kb
  • [2024-10-21 11:30:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int M=3e5+5,mod=998244353;
int n,m,blk,f[M],g[M];
int read(){
    int x=0;char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
    return x;
}
int rdc(int x){return x>=mod?x-mod:x;}
void init(int n){
    f[0]=g[0]=1;
    blk=ceil(sqrt(n));
    for (int i=1;i<=blk;i++){
        int p=i*i;
        for (int rep=0;rep<2;rep++)
            for (int j=i;j<=n-p;j++)
                f[j]=rdc(f[j]+f[j-i]);
        for (int j=p;j<=n;j++)
            g[j]=rdc(g[j]+f[j-p]);
    }
}
void solve(){
    n=read();m=read();
    for (int i=0;i<=m;i++) f[i]=g[i];
    for (int i=1;i<=n;i++){
        int x=read();
        for (int j=m;j>=x;j--)
            f[j]=rdc(f[j]+mod-f[j-x]);
    }
    printf("%d\n",f[m]);
}
int main(){init(3e5);int T=read();while (T--) solve();return 0;}

詳細信息

Test #1:

score: 100
Accepted
time: 209ms
memory: 6212kb

input:

5
1 4
1
1 4
2
1 4
3
3 4
1 2 3
4 4
1 2 3 4

output:

2
3
4
1
0

result:

ok 5 tokens

Test #2:

score: -100
Wrong Answer
time: 213ms
memory: 6212kb

input:

500
1 2921
832
1 1952
1842
1 1890
1711
1 2710
2136
1 1420
118
1 1427
921
1 1436
1346
1 1099
676
1 1146
75
1 1993
963
1 2819
34
1 1830
19
1 2900
1912
1 1070
993
1 2114
1434
1 2115
457
1 1407
888
1 1374
98
1 1450
555
1 2740
1469
1 2983
490
1 2209
418
1 2698
2671
1 2653
734
1 1707
1674
1 1247
527
1 147...

output:

534331308
826778795
787427970
116335786
656062179
132106757
17765543
361375797
643194883
887975470
921626129
436755061
876475876
630746069
905154023
431660970
382678132
532407817
371248392
204496571
699064370
569327593
744812919
782114486
75271714
966181965
377593956
964450666
952326515
726080378
45...

result:

wrong answer 1st words differ - expected: '656513071', found: '534331308'