QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#763042 | #8049. Equal Sums | Grain_Depot08 | WA | 0ms | 6040kb | C++14 | 1.1kb | 2024-11-19 17:57:08 | 2024-11-19 17:57:08 |
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]);
f[0][0][N]=1;
for(int i=0;i<=500;++i)
s[0][0][N+i]=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,a[i])])%mod-s[i][j-1][N+k-y[j]-1]+mod)%mod;
}else{
if(i&&b[i]>=max(-k+1,a[i]))f[i][j][N+k]=((f[i][j][N+k]+s[i-1][j][N+k-max(-k+1,a[i])])%mod-s[i-1][j][N+k-b[i]-1]+mod)%mod;
if(j&&y[j]>=max(-k+1,x[j]))f[i][j][N+k]=((f[i][j][N+k]+s[i][j-1][N+k-max(-k+1,x[j])])%mod-s[i][j-1][N+k-y[j]-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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 6040kb
input:
2 3 1 2 2 3 1 4 2 2 1 3
output:
0 0 0 0 0 0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'