QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#797199#9798. Safety FirstsolunarTL 12ms66260kbC++11895b2024-12-02 18:56:452024-12-02 18:56:45

Judging History

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

  • [2024-12-02 18:56:45]
  • 评测
  • 测评结果:TL
  • 用时:12ms
  • 内存:66260kb
  • [2024-12-02 18:56:45]
  • 提交

answer

// 2024ICPCShenyangE 
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <memory.h>

#define MOD 998244353
long long dp[2][2002][2002];

int main() {
	int t, n, m;
	
	cin >> t;
	while (t--) {
		cin >> n >> m;
		memset(dp, 0, sizeof(dp));
		for (int h = 1; h <= m; h++)
			dp[1][h][h] = 1;
		for (int i = 2; i <= n; i++) {
			for (int h = 1; h <= m; h++) {
				for (int d = 1; d <= h; d++) {
					dp[i % 2][h][d] = 0;
					for (int d1 = d; d1 <= h; d1++) {
						dp[i % 2][h][d] += (d < h ? dp[1 - i % 2][h - d][d1] : 0) + dp[1 - i % 2][h][d1];
						dp[i % 2][h][d] = dp[i % 2][h][d] % MOD;
					}
				}
			}
		}
		long long ans = 0;
		for (int d = 1; d <= m; d++)
			ans = (ans + dp[n % 2][m][d]) % MOD;
		cout << ans << endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 12ms
memory: 66260kb

input:

3
1 3
2 3
3 3

output:

1
4
10

result:

ok 3 number(s): "1 4 10"

Test #2:

score: -100
Time Limit Exceeded

input:

1
2000 2000

output:


result: