QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#765784 | #8049. Equal Sums | -xcxxx- | WA | 592ms | 1001864kb | C++14 | 1.3kb | 2024-11-20 15:16:11 | 2024-11-20 15:16:16 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,l,r) for(int i=(l);i>=(r);i--)
using namespace std;
int rd() {int x=0,f=1;char c=getchar();while(!isdigit(c))f=c=='-'?-1:f,c=getchar();while(isdigit(c))x=x*10+(c^48),c=getchar();return x*f;}
const int N=505,mod=998244353;
int qp(int a,int k=mod-2) {int r=1;for(;k;k>>=1,a=1ll*a*a%mod)if(k&1)r=1ll*r*a%mod;return r;}
int n,m,lx[N],rx[N],ly[N],ry[N],fac[N],inv[N];
void init() {
fac[0]=1;
rep(i,1,N-1) fac[i]=1ll*fac[i-1]*i%mod;
inv[N-1]=qp(fac[N-1]);
per(i,N-1,1) inv[i-1]=1ll*inv[i]*i%mod;
}
template<int L,int R>struct Array{int a[R-L+1];int &operator[](int i){return a[i-L];}};
Array<-N,N> dp[N][N];
signed main() {
n=rd(),m=rd();
init();
rep(i,1,n) lx[i]=rd(),rx[i]=rd();
rep(i,1,m) ly[i]=rd(),ry[i]=rd();
rep(i,0,n) rep(j,0,m) rep(s,-500,500) dp[i][j][s]=0;
dp[0][0][0]=1;
rep(i,0,n) rep(j,0,m) {
if(i|j) rep(s,-500,500) dp[i][j][s]+=dp[i][j][s-1];
rep(s,-500,500) {
if(s>=0) dp[i][j+1][s-ry[j+1]]+=dp[i][j][s],dp[i][j+1][s-ly[j+1]+1]-=dp[i][j][s];
if(s<0) dp[i+1][j][s+lx[i+1]]+=dp[i][j][s],dp[i+1][j][s+rx[i+1]+1]-=dp[i][j][s];
}
}
rep(i,1,n) {
rep(j,1,m) printf("%d ",(dp[i][j][0]+mod)%mod);
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 9952kb
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: 592ms
memory: 1001864kb
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 673005095 759395052 422187513 -520669290 -209793118 -620414729 560732652 -432329851 113141173 969768864 -866897478 805791248 -515880980 528937962 -263209723 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 5th numbers differ - expected: '180581065', found: '759395052'