QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#764336 | #8049. Equal Sums | byron10000 | WA | 1ms | 3732kb | C++14 | 1.6kb | 2024-11-20 08:46:12 | 2024-11-20 08:46:49 |
Judging History
answer
#if defined(_USE_PCH_)
#include "pch.hpp"
#else
#include <bits/stdc++.h>
#endif
#define RNG(V_, A_, B_, ...) for(int V_=(A_), V_##_END=(B_) __VA_OPT__(,) __VA_ARGS__; V_<=V_##_END; V_++)
#define IRNG(V_, A_, B_, ...) for(int V_=(A_), V_##_END=(B_) __VA_OPT__(,) __VA_ARGS__; V_>=V_##_END; V_--)
#ifdef _WIN32
#define long int64_t
#endif
#define fi first
#define se second
#define _UN using namespace
using namespace std;
typedef pair<int,int> pii;
typedef __int128 i128;
const int MAXN=510; const long MOD=998244353;
int n,m;
struct{ int l,r; } A[MAXN],B[MAXN];
int F[MAXN][MAXN][MAXN*2];
void addto(int& x,long y){ x=int((x+y+MOD)%MOD); }
int main(){
#if defined(_LOCAL_)
freopen("in","r",stdin);
// freopen("out","w",stdout);
// freopen("/dev/null","w",stderr);
#else
// freopen("0.in","r",stdin);
// freopen("0.out","w",stdout);
#endif
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
cin>>n>>m;
RNG(i,1,n) cin>>A[i].l>>A[i].r;
RNG(i,1,m) cin>>B[i].l>>B[i].r;
const auto M=501;
F[0][0][M]=1,F[0][0][M+1]=M-1;
RNG(i,0,n){
RNG(j,0,m){
RNG(a,-M+1,M){
addto(F[i][j][M+a],F[i][j][M+a-1]);
if(!F[i][j][M+a]) continue;
if(i<n&&a<=0) addto(F[i+1][j][M+a+A[i+1].l],F[i][j][M+a]),addto(F[i+1][j][M+a+A[i+1].r+1],-F[i][j][M+a]);
if(j<m&&a>0) addto(F[i][j+1][M+a-B[j+1].r],F[i][j][M+a]),addto(F[i][j+1][M+a-B[j+1].l+1],-F[i][j][M+a]);
}
}
}
RNG(i,1,n){
RNG(j,1,m) cout<<F[i][j][M]<<" ";
cout<<"\n";
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3732kb
input:
2 3 1 2 2 3 1 4 2 2 1 3
output:
2507 4008 12024 504 4012 21547
result:
wrong answer 1st numbers differ - expected: '2', found: '2507'