QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#763367 | #8049. Equal Sums | Grain_Depot08 | WA | 0ms | 5904kb | C++14 | 1.2kb | 2024-11-19 19:50:23 | 2024-11-19 19:50:24 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define N 505
int n,m,f[N][N][N+N],s[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]);
int u=x[i],v=y[i];
x[i]=-v;y[i]=-u;
}
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&&b[i]>=max(k,a[i])){
f[i][j][N+k]=((f[i][j][N+k]+s[i-1][j][N+k-max(k,a[i])])%mod-s[i-1][j][N+k-b[i]-1]+mod)%mod;
}
if(j&&y[j]>=max(k,x[j])){
f[i][j][N+k]=((f[i][j][N+k]+s[i][j-1][N+k-max(k,x[j])])%mod-s[i][j-1][N+k-y[j]-1]+mod)%mod;
}
}else{
if(i&&min(b[i],k-1)>=a[i]){
f[i][j][N+k]=((f[i][j][N+k]+s[i-1][j][N+k-a[i]])%mod-s[i-1][j][N+k-min(b[i],k-1)-1]+mod)%mod;
}
if(j&&min(y[j],k-1)>=x[j]){
f[i][j][N+k]=((f[i][j][N+k]+s[i][j-1][N+k-x[j]])%mod-s[i][j-1][N+k-min(y[j],k-1)-1]+mod)%mod;
}
}
}
for(int k=-500;k<=500;++k)
s[i][j][N+k]=(s[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: 5904kb
input:
2 3 1 2 2 3 1 4 2 2 1 3
output:
2 0 0 0 4 0
result:
wrong answer 4th numbers differ - expected: '3', found: '0'