QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#765716#8049. Equal Sums-xcxxx-RE 0ms0kbC++141.2kb2024-11-20 15:04:262024-11-20 15:04:27

Judging History

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

  • [2024-11-20 15:04:27]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-20 15:04:26]
  • 提交

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) rep(s,-500,500) {
        if(s>=0) rep(t,ly[j+1],ry[j+1]) (dp[i][j+1][s-t]+=dp[i][j][s])%=mod;
        if(s<0) rep(t,lx[i+1],rx[i+1]) (dp[i+1][j][s+t]+=dp[i][j][s])%=mod;
    }
    rep(i,1,n) {
        rep(j,1,m) printf("%d ",dp[i][j][0]);
        puts("");
    }
    return 0;
}

详细

Test #1:

score: 0
Runtime Error

input:

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

output:


result: