QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#767411 | #8049. Equal Sums | Alphys | WA | 1683ms | 14100kb | C++14 | 1023b | 2024-11-20 20:52:35 | 2024-11-20 20:52:36 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 998244353;
const int N = 510;
int n,m;
ll f[N][N*2+10],sum[N][N*2+10],ans[N][N];
int l[2][N],r[2][N];
int main(){
scanf("%d%d", &n, &m);
for(int i=1;i<=n;i++)scanf("%d%d", &l[0][i], &r[0][i]);
for(int i=1;i<=m;i++)scanf("%d%d", &l[1][i], &r[1][i]);
for(int i=0;i<=500;i++)sum[0][i+N]=1;
for(int len=1;len<=n+m;len++){
memset(f,0,sizeof(f));
for(int i=max(0,len-m),j=len-i;i<=n&&~j;i++,j--){
for(int v=-500;v<=500;v++){
if(v>0&&i)
f[i][v+N]=(sum[i-1][v+N-l[0][i]]-sum[i-1][v+N-r[0][i]-1]+MOD)%MOD;
else if(j)
f[i][v+N]=(sum[i][v+N+r[1][j]]-sum[i][v+N+l[1][j]-1]+MOD)%MOD;
}
ans[i][j]=f[i][N];
}
memset(sum,0,sizeof(sum));
for(int i=max(0,len-m),j=len-i;i<=n&&~j;i++,j--)
for(int v=-500;v<=500;v++)
sum[i][v+N]=(sum[i][v+N-1]+f[i][v+N])%MOD;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)printf("%lld ", ans[i][j]);
putchar('\n');
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 13272kb
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: 1683ms
memory: 14100kb
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 998238676 949301766 428921194 48025100 834254491 92352036 973975629 679530643 359218396 118380968 98425206 596808456 76911110 312250332 776066156 159978367 260204091 262437363 827202956 951386796 377829039 633034496 113987259 847013597 63013549 164926552 237149137 426911182 847448839 736069691 8...
result:
wrong answer 2nd numbers differ - expected: '79401', found: '998238676'