結果

問題 No.1492 01文字列と転倒
ユーザー kotatsugamekotatsugame
提出日時 2021-04-30 21:33:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 233 ms / 4,000 ms
コード長 599 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 65,080 KB
実行使用メモリ 11,476 KB
最終ジャッジ日時 2023-09-26 04:35:04
合計ジャッジ時間 3,565 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,392 KB
testcase_01 AC 3 ms
7,436 KB
testcase_02 AC 233 ms
11,476 KB
testcase_03 AC 214 ms
11,244 KB
testcase_04 AC 195 ms
11,136 KB
testcase_05 AC 163 ms
10,724 KB
testcase_06 AC 170 ms
10,820 KB
testcase_07 AC 183 ms
11,092 KB
testcase_08 AC 227 ms
11,272 KB
testcase_09 AC 3 ms
7,712 KB
testcase_10 AC 2 ms
5,520 KB
testcase_11 AC 3 ms
7,464 KB
testcase_12 AC 2 ms
7,520 KB
testcase_13 AC 3 ms
5,412 KB
testcase_14 AC 170 ms
10,832 KB
testcase_15 AC 3 ms
7,776 KB
testcase_16 AC 6 ms
7,912 KB
testcase_17 AC 161 ms
10,828 KB
testcase_18 AC 6 ms
7,816 KB
testcase_19 AC 3 ms
7,480 KB
testcase_20 AC 5 ms
7,676 KB
testcase_21 AC 133 ms
10,320 KB
testcase_22 AC 5 ms
7,844 KB
testcase_23 AC 4 ms
7,628 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N,M;
int dp[2][101][10001];
main()
{
	cin>>N>>M;
	int now=0;
	dp[now][0][0]=1;
	for(int i=0;i<2*N;i++)
	{
		int nxt=1-now;
		for(int j=0;j<=N;j++)for(int k=0;k<=N*N;k++)dp[nxt][j][k]=0;
		for(int j=0;j<=N;j++)for(int k=0;k<=N*N;k++)if(dp[now][j][k])
		{
			int l=i-j;
			if(j<N&&k+l<=N*N)
			{
				dp[nxt][j+1][k+l]+=dp[now][j][k];
				if(dp[nxt][j+1][k+l]>=M)dp[nxt][j+1][k+l]-=M;
			}
			if(l<j)
			{
				dp[nxt][j][k]+=dp[now][j][k];
				if(dp[nxt][j][k]>=M)dp[nxt][j][k]-=M;
			}
		}
		now=nxt;
	}
	for(int i=0;i<=N*N;i++)cout<<dp[now][N][i]<<"\n";
}
0