QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#817710 | #8839. Knocker | rotcar07 | WA | 2ms | 22320kb | C++23 | 1.2kb | 2024-12-17 10:49:45 | 2024-12-17 10:49:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int N=10005,mod=998244353;
int n,a[N],dp[N][N];
inline void red(int&x){x>=mod&&(x-=mod);}
int main(){
std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;for(int i=1;i<=n;i++) cin>>a[i];
sort(a+1,a+n+1);
for(int i=0;i<=a[n];i++)dp[0][i]=1;
for(int i=1,pos=1;i<=a[n]+1;i++){
long long res=1;
int cur=a[pos]/2+1;
if(a[pos]+1!=i){for(int j=0;j<=a[n];j++)red(dp[i][j]=dp[i-1][j]+mod-(i>1?dp[i-2][j]:0));goto cinema;}
for(int k=a[pos]/2+1;k<=a[pos];k++) res+=dp[k][a[pos]-k+1]-dp[k-1][a[pos]-k+1];
res=(res%mod+mod)%mod;
dp[i][0]=(res%=mod);
for(int j=1;j<=a[pos];j++){
if(j>cur) res-=dp[cur][max(j,a[pos]-cur+1)]-dp[cur-1][max(j,a[pos]-cur+1)],cur++;
int ps=max(a[pos]-j+2,cur)-1;
res+=dp[a[pos]][j]-dp[ps][j]-dp[a[pos]][j-1]+dp[ps][j-1];
res=(res%mod+mod)%mod;
dp[i][j]=res;
}
for(int j=a[pos]+1;j<=a[n];j++) dp[i][j]=1;
pos++;
cinema:
for(int j=0;j<=a[n];j++) red(dp[i][j]+=dp[i-1][j]);
}
cout<<(dp[a[n]+1][0]-dp[a[n]][0]+mod)%mod<<'\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3500kb
input:
1 5
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
2 6 5
output:
7
result:
ok 1 number(s): "7"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
5 1 2 4 8 16
output:
69
result:
ok 1 number(s): "69"
Test #4:
score: 0
Accepted
time: 1ms
memory: 9752kb
input:
1 139
output:
71
result:
ok 1 number(s): "71"
Test #5:
score: 0
Accepted
time: 0ms
memory: 16120kb
input:
2 359 96
output:
3661
result:
ok 1 number(s): "3661"
Test #6:
score: 0
Accepted
time: 0ms
memory: 22320kb
input:
3 487 237 391
output:
1727635
result:
ok 1 number(s): "1727635"
Test #7:
score: 0
Accepted
time: 0ms
memory: 20148kb
input:
4 411 81 149 407
output:
789553
result:
ok 1 number(s): "789553"
Test #8:
score: 0
Accepted
time: 0ms
memory: 20104kb
input:
5 39 221 395 89 173
output:
29269116
result:
ok 1 number(s): "29269116"
Test #9:
score: 0
Accepted
time: 0ms
memory: 20120kb
input:
6 259 270 448 54 426 167
output:
813709483
result:
ok 1 number(s): "813709483"
Test #10:
score: 0
Accepted
time: 0ms
memory: 22188kb
input:
7 387 422 398 32 488 136 372
output:
407011330
result:
ok 1 number(s): "407011330"
Test #11:
score: 0
Accepted
time: 0ms
memory: 22132kb
input:
8 15 63 451 213 37 209 343 319
output:
141747374
result:
ok 1 number(s): "141747374"
Test #12:
score: 0
Accepted
time: 2ms
memory: 22248kb
input:
9 439 407 197 191 291 486 30 307 11
output:
727389889
result:
ok 1 number(s): "727389889"
Test #13:
score: -100
Wrong Answer
time: 0ms
memory: 21980kb
input:
10 18 18 71 471 121 362 467 107 138 254
output:
10
result:
wrong answer 1st numbers differ - expected: '118253787', found: '10'