QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#600170#8049. Equal Sumsuser10086RE 1ms5668kbC++171.3kb2024-09-29 15:10:372024-09-29 15:10:37

Judging History

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

  • [2024-09-29 15:10:37]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:5668kb
  • [2024-09-29 15:10:37]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 510, MOD = 998244353, V = 10;

int n, m, l[N], r[N], s[N], t[N], ans[N][N];
int dp[N][N << 1], nxt[N][N << 1];

signed main()
{
	cin.tie(0)->sync_with_stdio(0);
	
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> l[i] >> r[i];
	for (int j = 1; j <= m; j++) cin >> s[j] >> t[j];
	dp[0][0 + V] = 1;
	for (int sum = 0; sum < n + m; sum++)
	{
		for (int i = 0; i <= sum; i++)
		{
			int j = sum - i;
			for (int d = -V; d <= V; d++)
			{
				int v = dp[i][d + V];
				if (!v) continue;
//				printf("***%d %d\n", d - t[j + 1] + V, d - s[j + 1] + 1 + V);
				if (d < 0) (nxt[i + 1][d + l[i + 1] + V] += v) %= MOD, (nxt[i + 1][d + r[i + 1] + 1 + V] -= v) %= MOD;
				else (nxt[i][d - t[j + 1] + V] += v) %= MOD, (nxt[i][d - s[j + 1] + 1 + V] -= v) %= MOD;
			}
		}
		for (int i = 0; i <= sum; i++)
		{
			int j = sum + 1 - i;
			dp[i][-V + V] = nxt[i][-V + V];
			for (int d = -V + 1; d <= V; d++) (dp[i][d + V] = dp[i][d - 1 + V] + nxt[i][d + V]) %= MOD;//, printf("dp(%d, %d, %d) = %d\n", i, j, d, dp[i][d + V]);
			ans[i][j] = dp[i][0 + V];
		}
		for (int i = 0; i <= sum; i++)
			for (int d = -V; d <= V; d++) nxt[i][d + V] = 0;
	}
	for (int a = 1; a <= n; a++, cout << '\n')
		for (int b = 1; b <= m; b++)
			cout << ans[a][b] << ' ';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5668kb

input:

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

output:

2 0 0 
3 4 4 

result:

ok 6 numbers

Test #2:

score: -100
Runtime Error

input:

500 500
19 458
1 480
7 485
50 461
12 476
15 461
48 466
40 453
46 467
9 458
27 478
26 472
46 459
29 490
6 500
17 487
48 484
28 472
28 459
25 480
4 491
29 481
36 460
2 491
44 499
22 473
20 458
4 483
27 471
2 496
11 461
43 450
2 478
37 466
15 459
42 482
7 451
19 455
2 453
47 475
48 450
1 474
46 471
9 4...

output:


result: