QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#711859 | #8049. Equal Sums | acwing_gza# | WA | 1870ms | 13172kb | C++14 | 2.6kb | 2024-11-05 13:47:47 | 2024-11-05 13:48:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace gza{
#define int long long
#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[2][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)
{
int now=i&1,pre=now^1;
if(i) m1(f[now],0);
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,0ll);
if(l<=r) (f[now][j][k+500]+=f[pre][j][r+500]-(l==-500?0:f[pre][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,1ll);
// if(i==0&&j==1) cout<<k<<' '<<l<<' '<<r<<endl;
if(l<=r) (f[now][j][k+500]+=f[now][j-1][r+500]-(l==-500?0:f[now][j-1][l-1+500]))%=mod;
}
}
fo(k,-499,500) (f[now][j][k+500]+=f[now][j][k-1+500])%=mod;
if(i>=1&&j>=1) write((f[now][j][500]-f[now][j][499]+mod)%mod),pc(" \n"[j==m]);
}
}
}
}
signed main(){
gza::main();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 13172kb
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: 1870ms
memory: 12572kb
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 898492182 230600915 818284078 579063468 919275835 895918065 60548010 789028514 475053791 595189286 897242235 532615626 108744442 243201729 4860227 112137991 948215926 919011597 861381291 891616354 597851338 23274143 303420992 819106633 29800748 129107776 824788469 644590014 451884510 683483860 7...
result:
wrong answer 2nd numbers differ - expected: '79401', found: '898492182'