QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#797199 | #9798. Safety First | solunar | TL | 12ms | 66260kb | C++11 | 895b | 2024-12-02 18:56:45 | 2024-12-02 18:56:45 |
Judging History
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