結果

問題 No.1492 01文字列と転倒
ユーザー rtyurtyu
提出日時 2021-10-19 14:09:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,087 ms / 4,000 ms
コード長 559 bytes
コンパイル時間 786 ms
コンパイル使用メモリ 67,848 KB
実行使用メモリ 19,768 KB
最終ジャッジ日時 2024-09-20 06:21:24
合計ジャッジ時間 10,336 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1,063 ms
19,768 KB
testcase_03 AC 1,012 ms
19,524 KB
testcase_04 AC 924 ms
19,216 KB
testcase_05 AC 791 ms
18,252 KB
testcase_06 AC 817 ms
18,460 KB
testcase_07 AC 882 ms
19,000 KB
testcase_08 AC 1,087 ms
19,684 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 827 ms
18,612 KB
testcase_15 AC 4 ms
7,636 KB
testcase_16 AC 18 ms
7,988 KB
testcase_17 AC 781 ms
18,380 KB
testcase_18 AC 19 ms
7,948 KB
testcase_19 AC 3 ms
6,944 KB
testcase_20 AC 12 ms
7,920 KB
testcase_21 AC 645 ms
17,532 KB
testcase_22 AC 18 ms
7,972 KB
testcase_23 AC 9 ms
7,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

long long d[2][109][10009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; long long md; cin >> n >> md;
	d[0][0][0] = 1;
	for (int i = 1; i <= 2 * n; i++)
		for (int j = 0; j <= i / 2; j++)
			for (int k = 0; k <= n * n; k++) {
				if (k >= j) d[(i & 1)][j][k] = d[!(i & 1)][j][k - j];
				else d[(i & 1)][j][k] = 0;
				if (j) d[(i & 1)][j][k] = (d[(i & 1)][j][k] + d[!(i & 1)][j - 1][k]) % md;
			}
	for (int i = 0; i <= n * n; i++)
		cout << d[0][n][i] << '\n';
	return 0;
}
0