QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#613937 | #8049. Equal Sums | free_windy | WA | 1670ms | 1002152kb | C++20 | 1.1kb | 2024-10-05 15:06:02 | 2024-10-05 15:11:04 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline int read(){
int s=0,z=1;
char c=getchar();
while(c<'0'||c>'9'){
if(c=='-')z=-1;
c=getchar();
}
while(c>='0'&&c<='9'){
s=(s<<3)+(s<<1)+(c^48);
c=getchar();
}
return s*z;
}
const int N = 505;
const int mod = 998244353;
int n,m;
int f[N][N][N*2];
int la[N],lb[N],ra[N],rb[N];
int main(){
n=read(),m=read();
for(int i=1;i<=n;i++){
la[i]=read(),ra[i]=read();
}
for(int i=1;i<=m;i++){
lb[i]=read(),rb[i]=read();
}
f[0][0][501]=1;
for(int i=501;i<=1001;i++) f[0][0][i]=1;
for(int i=0;i<=n;i++){
for(int j=0;j<=m;j++){
if(!i&&!j) continue;
for(int k=1;k<=1001;k++){
if(i!=0)f[i][j][k]=f[i-1][j][min(max(0,k-la[i]),501)]-f[i-1][j][min(max(0,k-ra[i]-1),501)];
if(j!=0)f[i][j][k]+=f[i][j-1][max(min(1001,k+rb[j]),501)]-f[i][j-1][max(min(1001,k+lb[j]-1),501)];
f[i][j][k]=(f[i][j][k]%mod+mod)%mod;
f[i][j][k]=(f[i][j][k]+f[i][j][k-1])%mod;
}
}
}
for(int i=1;i<=n;i++){
for(int l=1;l<=m;l++){
cout<<f[i][l][501]-f[i][l][500]<<" ";
}
cout<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7724kb
input:
2 3 1 2 2 3 1 4 2 2 1 3
output:
2 0 0 3 4 4
result:
ok 6 numbers
Test #2:
score: -100
Wrong Answer
time: 1670ms
memory: 1002152kb
input:
500 500 19 458 1 480 7 485 50 461 12 476 15 461 48 466 40 453 46 467 9 458 27 478 26 472 46 459 29 490 6 500 17 487 48 484 28 472 28 459 25 480 4 491 29 481 36 460 2 491 44 499 22 473 20 458 4 483 27 471 2 496 11 461 43 450 2 478 37 466 15 459 42 482 7 451 19 455 2 453 47 475 48 450 1 474 46 471 9 4...
output:
411 79401 9145270 -325239258 -817663288 -14021235 586589234 -705201083 404363796 -132882629 -332756365 118838806 -72054409 226338288 521479857 808644951 -212203065 -657475332 177100 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
wrong answer 4th numbers differ - expected: '673005095', found: '-325239258'