QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#335895#8049. Equal Sumseggegg185WA 1ms5704kbC++14992b2024-02-24 08:54:572024-02-24 08:54:58

Judging History

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

  • [2024-02-24 08:54:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5704kb
  • [2024-02-24 08:54:57]
  • 提交

answer

#include <iostream>
using namespace std;
#define int long long
const int O = 502,mod = 998244353;
int n,m,dp[505][505][1010],lx[505],rx[505],ly[505],ry[505];
int sum(int x,int y,int l,int r) {
	return (dp[x][y][r]-(l?dp[x][y][l-1]:0)+mod)%mod;
}
signed main() {
	cin.tie(0)->sync_with_stdio(false);
	int n,m; 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];
	for(int i = O; i <= O+O; i++) dp[0][0][i] = 1;
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= m; j++) {
			if(i == j && j == 0) continue;
			for(int k = 0; k <= O+O; k++) {
				if(k > O) {
					if(i) dp[i][j][k] = sum(i-1,j,k-rx[i],k-lx[i]);
					else dp[i][j][k] = 0;
				} else {
					if(j) dp[i][j][k] = sum(i,j-1,k+rx[i],k+lx[i]);
					else dp[i][j][k] = 0;
				}
				if(i && j && (k==O)) {cout << dp[i][j][k] << ' ';
				if(j == m) cout << endl;}
				if(k) (dp[i][j][k] += dp[i][j][k-1]) %= mod;
			}
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5704kb

input:

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

output:

0 0 0 
0 0 0 

result:

wrong answer 1st numbers differ - expected: '2', found: '0'