結果

問題 No.1492 01文字列と転倒
ユーザー snrnsidysnrnsidy
提出日時 2021-05-20 05:54:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 641 ms / 4,000 ms
コード長 895 bytes
コンパイル時間 2,758 ms
コンパイル使用メモリ 206,132 KB
実行使用メモリ 19,412 KB
最終ジャッジ日時 2024-04-18 13:58:21
合計ジャッジ時間 9,586 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
19,392 KB
testcase_01 AC 21 ms
19,364 KB
testcase_02 AC 615 ms
19,156 KB
testcase_03 AC 593 ms
19,412 KB
testcase_04 AC 562 ms
19,232 KB
testcase_05 AC 511 ms
19,276 KB
testcase_06 AC 528 ms
19,336 KB
testcase_07 AC 545 ms
19,388 KB
testcase_08 AC 641 ms
19,336 KB
testcase_09 AC 28 ms
19,348 KB
testcase_10 AC 16 ms
19,340 KB
testcase_11 AC 25 ms
19,328 KB
testcase_12 AC 24 ms
19,404 KB
testcase_13 AC 19 ms
19,372 KB
testcase_14 AC 509 ms
19,284 KB
testcase_15 AC 54 ms
19,404 KB
testcase_16 AC 95 ms
19,280 KB
testcase_17 AC 513 ms
19,404 KB
testcase_18 AC 97 ms
19,356 KB
testcase_19 AC 40 ms
19,272 KB
testcase_20 AC 86 ms
19,208 KB
testcase_21 AC 454 ms
19,136 KB
testcase_22 AC 90 ms
19,316 KB
testcase_23 AC 73 ms
19,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
 
using namespace std;

long long int dp[2][101][10001];

int main(void)
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

	long long int N,MOD;

	cin >> N >> MOD;

	dp[1][0][0] = 1;

	for(int i=0;i<2*N;i++)
	{
		memcpy(dp[0],dp[1],sizeof(dp[1]));
		memset(dp[1],0,sizeof(dp[1]));
		for(int j=0;j<=N;j++)
		{
			for(int k=0;k<=N*N;k++)
			{
				if(dp[0][j][k]==0) continue;
				int a = i - j;
				int b = j;
				//cout << i << ' ' << a << ' ' << b << ' ' << k << '\n';
				if(b+1<=a && b+1<=N)
				{
					dp[1][b+1][k] += dp[0][j][k];
					dp[1][b+1][k]%=MOD;
				}
				if(a+1<=N && k + b <= N*N)
				{
					dp[1][b][k + b] += dp[0][b][k];
					dp[1][b][k+b]%=MOD;
				}
			}
		}
	}

	for(int i=0;i<=N*N;i++)
	{
		long long int res = 0;
		for(int j=0;j<=N;j++)
		{
			res += dp[1][j][i];
			res%=MOD;
		}
		cout << res << '\n';
	}
	return 0;
}
0