結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,676 KB
testcase_01 AC 3 ms
7,684 KB
testcase_02 AC 1,162 ms
20,628 KB
testcase_03 AC 1,072 ms
20,628 KB
testcase_04 AC 984 ms
20,444 KB
testcase_05 AC 835 ms
19,928 KB
testcase_06 AC 869 ms
20,060 KB
testcase_07 AC 947 ms
20,312 KB
testcase_08 AC 1,158 ms
20,628 KB
testcase_09 AC 3 ms
7,708 KB
testcase_10 AC 3 ms
7,676 KB
testcase_11 AC 3 ms
7,688 KB
testcase_12 AC 3 ms
7,688 KB
testcase_13 AC 2 ms
7,680 KB
testcase_14 AC 867 ms
20,060 KB
testcase_15 AC 4 ms
9,860 KB
testcase_16 AC 19 ms
10,208 KB
testcase_17 AC 841 ms
19,928 KB
testcase_18 AC 21 ms
12,292 KB
testcase_19 AC 4 ms
9,808 KB
testcase_20 AC 15 ms
10,124 KB
testcase_21 AC 702 ms
19,444 KB
testcase_22 AC 19 ms
10,208 KB
testcase_23 AC 10 ms
10,016 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