QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#478094 | #8049. Equal Sums | maojun | WA | 2ms | 10064kb | C++23 | 915b | 2024-07-14 16:45:21 | 2024-07-14 16:45:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=505,MOD=998244353;
int n,m,lx[N],rx[N],ly[N],ry[N];
int dp[N][N][N+N],g[N][N][N+N];
inline int add(int x,int y){x+=y;return x>=MOD?x-MOD:x;}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%d%d",&lx[i],&rx[i]);
for(int i=1;i<=m;i++)scanf("%d%d",&ly[i],&ry[i]);
fill(g[0][0]+N,g[0][0]+N+N,1);
for(int i=0;i<=n;i++){
for(int j=0;j<=m;j++){
if(j)for(int k=-500;k<0;k++)dp[i][j][N+k]=add(g[i][j-1][N+k+ry[j]],MOD-g[i][j-1][N+k+ly[j]-1]);
if(i)for(int k=0;k<=500;k++)dp[i][j][N+k]=add(g[i-1][j][N+k-lx[i]],MOD-g[i-1][j][N+k-rx[i]-1]);
if(i||j)for(int k=-500;k<=500;k++)g[i][j][N+k]=add(g[i][j][N+k-1],dp[i][j][N+k]);
if(i&&j)printf("%d ",dp[i][j][N]);
}
if(i)puts("");
}
for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
for(int k=-10;k<=10;k++)printf("%d ",g[i][j][N+k]);
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 10064kb
input:
2 3 1 2 2 3 1 4 2 2 1 3
output:
2 0 0 3 4 4 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 2 3 4 4 4 4 4 4 4 4 4 4 4 4 0 0 0 0 1 2 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 0 1 3 6 9 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 2 2 2 2 2 2 0 0 0 0 0 0 0 1 3 5 7 8 8 8 8 8 8 8 8 8 8 0 0 0 0 0 1 ...
result:
wrong answer Output contains longer sequence [length = 258], but answer contains 6 elements