結果

問題 No.1761 Sequence Distance
ユーザー 👑 ygussanyygussany
提出日時 2021-11-20 16:16:37
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 919 bytes
コンパイル時間 2,774 ms
コンパイル使用メモリ 66,000 KB
実行使用メモリ 11,020 KB
最終ジャッジ日時 2023-09-02 11:04:46
合計ジャッジ時間 20,598 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
10,988 KB
testcase_01 AC 4 ms
11,012 KB
testcase_02 AC 3,548 ms
10,912 KB
testcase_03 AC 4 ms
11,020 KB
testcase_04 AC 4 ms
10,868 KB
testcase_05 AC 4 ms
10,972 KB
testcase_06 AC 10 ms
10,984 KB
testcase_07 AC 5 ms
11,016 KB
testcase_08 AC 10 ms
10,872 KB
testcase_09 AC 5 ms
10,988 KB
testcase_10 AC 9 ms
10,868 KB
testcase_11 AC 15 ms
10,980 KB
testcase_12 AC 5 ms
10,884 KB
testcase_13 AC 6 ms
10,980 KB
testcase_14 AC 4 ms
11,012 KB
testcase_15 AC 10 ms
10,936 KB
testcase_16 AC 10 ms
10,996 KB
testcase_17 AC 5 ms
10,924 KB
testcase_18 AC 14 ms
10,988 KB
testcase_19 AC 7 ms
10,904 KB
testcase_20 AC 7 ms
10,976 KB
testcase_21 AC 2,034 ms
11,020 KB
testcase_22 AC 81 ms
10,980 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

const int Mod = 998244353;

int main()
{
	int N, M;
	scanf("%d %d", &N, &M);
	
	int i, j, k, cur, prev, dp[2][1003][1003] = {};
	dp[0][0][0] = 2;
	for (i = 2, cur = 1, prev = 0; i <= N; i++, cur ^= 1, prev ^= 1) {
		for (j = (i - 1 < M)? i - 1: M; j > 0; j--) {
			for (k = 0; k <= M; k++) {
				if (j == M) dp[cur][j][k] = dp[prev][j-1][k];
				else {
					dp[cur][j][k] = dp[cur][j+1][k] + dp[prev][j-1][k] - dp[prev][j][k];
					if (dp[cur][j][k] >= Mod) dp[cur][j][k] -= Mod;
					else if (dp[cur][j][k] < 0) dp[cur][j][k] += Mod;
				}
			}
			for (k = j; k <= M; k++) {
				dp[cur][j][k] += dp[prev][j][k-j];
				if (dp[cur][j][k] >= Mod) dp[cur][j][k] -= Mod;
			}
			if (j == i - 1) dp[cur][j][j]++;
		}
		for (k = 0; k <= M; k++) {
			dp[cur][0][k] = dp[cur][1][k] * 2;
			if (dp[cur][0][k] >= Mod) dp[cur][0][k] -= Mod;
		}
	}
	printf("%d\n", dp[prev][0][M]);
	fflush(stdout);
	return 0;
}
0