QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#763409 | #8049. Equal Sums | Grain_Depot08 | WA | 0ms | 4008kb | C++17 | 856b | 2024-11-19 20:07:59 | 2024-11-19 20:08:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define N 505
int n,m,f[N][N][N+N],a[N],b[N],x[N],y[N];
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i)scanf("%d%d",&a[i],&b[i]);
for(int i=1;i<=m;++i){
scanf("%d%d",&x[i],&y[i]);
x[i]=-x[i];y[i]=-y[i];
swap(x[i],y[i]);
}
f[0][0][N]=1;
for(int i=0;i<=n;++i){
for(int j=0;j<=m;++j){
for(int k=-500;k<=500;++k){
if(k>0){
if(i)f[i][j][N+k]=((f[i][j][N+k]+f[i-1][j][N+k-a[i]])%mod-f[i-1][j][N+k-b[i]-1]+mod)%mod;
}else{
if(j)f[i][j][N+k]=((f[i][j][N+k]+f[i][j-1][N+k-x[j]])%mod-f[i][j-1][N+k-y[j]-1]+mod)%mod;
}
}
for(int k=-500;k<=500;++k)
f[i][j][N+k]=(f[i][j][N+k-1]+f[i][j][N+k])%mod;
}
}
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j)
printf("%d ",f[i][j][N]);
printf("\n");
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4008kb
input:
2 3 1 2 2 3 1 4 2 2 1 3
output:
7 8 24 4 12 47
result:
wrong answer 1st numbers differ - expected: '2', found: '7'