QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#484982#8049. Equal Sumszhao_daodaoWA 4ms19548kbC++205.8kb2024-07-20 10:03:022024-07-20 10:03:02

Judging History

你现在查看的是最新测评结果

  • [2024-07-20 10:03:02]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:19548kb
  • [2024-07-20 10:03:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int MAXN=5e2+5,N=5e2+5;
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++){
            for(int k=-N;k<=N;k++)g[i&1][j][k]=g[i&1][j][k-1]+f[i&1][j][k];
            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<=N;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];
            if(i&&j)cout<<f[i&1][j][N]<<" ";
        }
        cout<<"\n";
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 19548kb

input:

2 3
1 2
2 3
1 4
2 2
1 3

output:



result:

wrong answer Answer contains longer sequence [length = 6], but output contains 0 elements