QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#777 | #484992 | #8049. Equal Sums | yz_ly | zhao_daodao | Failed. | 2024-08-11 19:29:41 | 2024-08-11 19:29:43 |
Details
Extra Test:
Accepted
time: 0ms
memory: 19572kb
input:
6 6 1 1 1 1 1 1 500 500 500 500 500 500 500 500 500 500 500 500 1 1 1 1 1 1
output:
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 1
result:
ok 36 numbers
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#484992 | #8049. Equal Sums | zhao_daodao | AC ✓ | 419ms | 19688kb | C++20 | 6.0kb | 2024-07-20 10:10:16 | 2024-07-20 10:10:16 |
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int MAXN=5e2+5,N=5e2;
namespace simpler{
template<const unsigned _Mod=INT32_MAX>
class modint{
protected:
int64_t _val;
typedef modint<_Mod> _mint;
friend inline _mint
__construct(_mint&& _res,int64_t _x){
_res._val=_x;
return _res;
}
template<class _Tp>friend _mint
__quickly_power(_mint _a,_Tp _b){
if(_b<=0)return 1;
_mint _res=1;
for(;(bool)_b;_b>>=1,_a*=_a)if(_b&1)_res*=_a;
return _res;
}
public:
modint():_val(0){}
template<class _Tp>modint(_Tp _x){
_val=((int64_t)_x%_Mod+_Mod)%_Mod;
}
template<class _Tp>explicit inline operator _Tp(){return (_Tp)_val;}
friend _mint operator+(const _mint& _a,const _mint& _b){
if(_a._val+_b._val>=_Mod)return __construct(_mint(),_a._val+_b._val-_Mod);
return __construct(_mint(),_a._val+_b._val);
}
inline _mint& operator+=(const _mint& _b){return *this=*this+_b;}
inline _mint& operator++(){return *this=*this+__construct(_mint(),1);}
inline _mint& operator++(int){
_mint _res=*this;*this=*this+__construct(_mint(),1);
return _res;
}//plus
friend _mint operator-(const _mint& _a,const _mint& _b){
if(_a._val-_b._val<0)return __construct(_mint(),_a._val-_b._val+_Mod);
return __construct(_mint(),_a._val-_b._val);
}
inline _mint& operator-=(const _mint& _b){return *this=*this-_b;}
inline _mint& operator--(){return *this=*this-__construct(_mint(),1);}
inline _mint& operator--(int){
_mint _res=*this;*this=*this-__construct(_mint(),1);
return _res;
}//minus
friend inline _mint
operator*(const _mint& _a,const _mint& _b){
return __construct(_mint(),_a._val*_b._val%_Mod);
}
inline _mint& operator*=(const _mint& _b){return *this=*this*_b;}//multiplies
_mint operator-(){return __construct(_mint(),_val?_Mod-_val:_val);}//negative
friend inline _mint
operator%(const _mint& _a,const _mint& _b){
return __construct(_mint(),_a._val%_b._val);
}
inline _mint& operator%=(const _mint& _b){return *this=*this%_b;}//modulus
friend inline bool
operator==(const _mint& _a,const _mint& _b){
return _a._val==_b._val;
}
friend inline bool
operator!=(const _mint& _a,const _mint& _b){
return _a._val!=_b._val;
}
friend inline bool
operator<(const _mint& _a,const _mint& _b){
return _a._val<_b._val;
}
friend inline bool
operator>(const _mint& _a,const _mint& _b){
return _a._val>_b._val;
}
friend inline bool
operator<=(const _mint& _a,const _mint& _b){
return _a._val<=_b._val;
}
friend inline bool
operator>=(const _mint& _a,const _mint& _b){
return _a._val>=_b._val;
}
friend inline _mint
operator&(const _mint& _a,const _mint& _b){
return _a._val&_b._val;
}
inline _mint& operator&=(const _mint& _b){return *this=*this&_b;}
friend inline _mint
operator|(const _mint& _a,const _mint& _b){
return _a._val|_b._val;
}
inline _mint& operator|=(const _mint& _b){return *this=*this|_b;}
friend inline _mint
operator^(const _mint& _a,const _mint& _b){
return _a._val^_b._val;
}
inline _mint& operator^=(const _mint& _b){return *this=*this^_b;}
friend inline _mint
operator<<(const _mint& _a,const _mint& _b){
return _a._val<<_b._val;
}
inline _mint& operator<<=(const _mint& _b){return *this=*this<<_b;}
friend inline _mint
operator>>(const _mint& _a,const _mint& _b){
return _a._val>>_b._val;
}
inline _mint& operator>>=(const _mint& _b){return *this=*this>>_b;}
inline _mint operator~()const{return __construct(_mint(),~_val);}
inline bool operator!()const{return !_val;}
friend inline std::istream&
operator>>(std::istream& _is,_mint& _b){
return _is>>_b._val;
}
friend inline std::ostream&
operator<<(std::ostream& _os,const _mint& _b){
return _os<<_b._val;
}
template<class _Tp>_mint
power(_Tp _n)const{
return __quickly_power(*this,_n);
}
inline _mint inv()const{return __quickly_power(*this,_Mod-2);}
friend inline _mint
operator/(const _mint& _a,const _mint& _b){
return __construct(_mint(),_a._val*_b.inv()._val%_Mod);
}
inline _mint& operator/=(const _mint& _b){return *this=*this/_b;}
};
}
using mint=simpler::modint<998244353>;
mint f[2][MAXN][MAXN<<1],g[2][MAXN][MAXN<<1];
int n,m,Lx[MAXN],Rx[MAXN],Ly[MAXN],Ry[MAXN];
signed main(){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>Lx[i]>>Rx[i];
for(int i=1;i<=m;i++)cin>>Ly[i]>>Ry[i];
f[0][0][N]=1;
for(int i=0;i<=n;i++){
for(int j=0;j<=m;j++){
if(i)for(int k=0;k<=N;k++)f[i&1][j][N+k]=g[i-1&1][j][N+k-Lx[i]]-g[i-1&1][j][N+k-Rx[i]-1];
if(j)for(int k=-N;k<0;k++)f[i&1][j][N+k]=g[i&1][j-1][N+k+Ry[j]]-g[i&1][j-1][N+k+Ly[j]-1];
for(int k=-N;k<=N;k++)g[i&1][j][k+N]=g[i&1][j][k+N-1]+f[i&1][j][k+N];
if(i&&j){
// cout<<i<<" "<<j<a<"\n";
// for(int k=N-10;k<=N+10;k++)
// cout<<f[i&1][j][k]<<" ";
// cout<<"\n";
cout<<f[i&1][j][N]<<" ";
}
}
cout<<"\n";
}
}