結果

問題 No.1761 Sequence Distance
ユーザー 👑 ygussanyygussany
提出日時 2021-11-20 16:16:01
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 962 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 36,740 KB
実行使用メモリ 9,808 KB
最終ジャッジ日時 2023-09-02 11:03:34
合計ジャッジ時間 14,524 ms
ジャッジサーバーID
(参考情報)
judge16 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,792 KB
testcase_01 AC 3 ms
9,716 KB
testcase_02 AC 2,146 ms
9,656 KB
testcase_03 AC 3 ms
9,728 KB
testcase_04 AC 3 ms
9,728 KB
testcase_05 AC 4 ms
9,700 KB
testcase_06 AC 7 ms
9,720 KB
testcase_07 AC 4 ms
9,596 KB
testcase_08 AC 7 ms
9,596 KB
testcase_09 AC 4 ms
9,696 KB
testcase_10 AC 7 ms
9,664 KB
testcase_11 AC 10 ms
9,796 KB
testcase_12 AC 4 ms
9,808 KB
testcase_13 AC 5 ms
9,712 KB
testcase_14 AC 4 ms
9,804 KB
testcase_15 AC 7 ms
9,716 KB
testcase_16 AC 7 ms
9,660 KB
testcase_17 AC 3 ms
9,712 KB
testcase_18 AC 10 ms
9,656 KB
testcase_19 AC 5 ms
9,652 KB
testcase_20 AC 4 ms
9,656 KB
testcase_21 AC 1,281 ms
9,704 KB
testcase_22 AC 50 ms
9,708 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 #

#pragma GCC optimize("Ofast,unroll-loops")
#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