QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#711837 | #8049. Equal Sums | acwing_gza# | WA | 2009ms | 1007764kb | C++14 | 2.5kb | 2024-11-05 13:42:44 | 2024-11-05 13:42:44 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace gza{
#define pb push_back
#define MT int TTT=R;while(TTT--)
#define pc putchar
#define R read()
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i>=b;i--)
#define m1(a,b) memset(a,b,sizeof a)
namespace IO
{
inline int read()
{
int x=0;
char ch=getchar();
bool f=0;
while(!isdigit(ch)){if(ch=='-') f=1;ch=getchar();}
while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
if(f) x=-x;
return x;
}
template<typename T> inline void write(T x)
{
if(x<0) pc('-'),x=-x;
if(x>9) write(x/10);
pc(x%10+'0');
}
};
namespace math
{
inline int gcd(int a,int b)
{
int az=__builtin_ctz(a),bz=__builtin_ctz(b),z=(az>bz)?bz:az,t;
b>>=bz;
while(a) a>>=az,t=a-b,b=a,az=__builtin_ctz(t<0?-t:t),a=t<0?-t:t;
return b<<z;
}
inline int qmi(int a,int b,int p)
{
int res=1;
while(b)
{
if(b&1) res=res*a%p;
a=a*a%p;
b>>=1;
}
return res;
}
const int MAXN=2e6+10;
int my_fac[MAXN],my_inv[MAXN];
void init_binom(int mod)
{
my_fac[0]=1;fo(i,1,min(MAXN,mod)-1) my_fac[i]=my_fac[i-1]*i%mod;
my_inv[min(MAXN,mod)-1]=qmi(my_fac[min(MAXN,mod)-1],mod-2,mod);rep(i,min(MAXN,mod)-2,0) my_inv[i]=my_inv[i+1]*(i+1)%mod;
}
int binom(int a,int b,int mod)
{
return my_fac[a]*my_inv[b]%mod*my_inv[a-b]%mod;
}
};
using namespace IO;
using namespace math;
const int N=510,mod=998244353;
int n,m;
int lx[N],rx[N],ly[N],ry[N];
int f[N][N][N<<1];
void main(){
n=R,m=R;
fo(i,1,n) lx[i]=R,rx[i]=R;
fo(i,1,m) ly[i]=R,ry[i]=R;
fo(i,500,1000) f[0][0][i]=1;
fo(i,0,n) fo(j,0,m) if(i!=0||j!=0)
{
fo(k,-500,500)
{
if(i)
{
int l=k-rx[i];
int r=k-lx[i];
r=min(r,0);
if(l<=r) (f[i][j][k+500]+=f[i-1][j][r+500]-(l==-500?0:f[i-1][j][l-1+500]))%=mod;
// if(i==1&&j==1&&k==0) cout<<l<<' '<<r<<' '<<f[i-1][j][r+500]-(l==-500?0:f[i-1][j][l-1+500])<<endl;
}
if(j)
{
int l=k+ly[j];
int r=k+ry[j];
l=max(l,1);
// if(i==0&&j==1) cout<<k<<' '<<l<<' '<<r<<endl;
if(l<=r) (f[i][j][k+500]+=f[i][j-1][r+500]-(l==-500?0:f[i][j-1][l-1+500]))%=mod;
}
}
fo(k,-499,500) (f[i][j][k+500]+=f[i][j][k-1+500])%=mod;
}
fo(a,1,n) fo(b,1,m) write((f[a][b][500]-f[a][b][499]+mod)%mod),pc(" \n"[b==m]);
}
}
signed main(){
gza::main();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5696kb
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: 2009ms
memory: 1007764kb
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 611004409 709346131 713198172 389349501 737981109 778316393 507856789 32642988 754568251 382661047 887863888 474129409 302923952 223837550 167366686 331695701 836246655 7428215 534452098 654106527 297728836 243530800 43506900 6909896 965893617 55747551 764295928 467181522 606579578 889457634 733...
result:
wrong answer 2nd numbers differ - expected: '79401', found: '611004409'