結果

問題 No.1492 01文字列と転倒
ユーザー 小野寺健小野寺健
提出日時 2021-05-04 17:10:50
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 690 bytes
コンパイル時間 5,712 ms
コンパイル使用メモリ 78,380 KB
実行使用メモリ 752,600 KB
最終ジャッジ日時 2023-09-30 18:47:10
合計ジャッジ時間 26,568 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,744 KB
testcase_01 AC 121 ms
53,688 KB
testcase_02 MLE -
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 AC 123 ms
53,892 KB
testcase_10 AC 118 ms
55,708 KB
testcase_11 AC 122 ms
55,412 KB
testcase_12 AC 124 ms
55,404 KB
testcase_13 AC 120 ms
55,408 KB
testcase_14 MLE -
testcase_15 AC 171 ms
55,952 KB
testcase_16 AC 241 ms
67,724 KB
testcase_17 MLE -
testcase_18 AC 225 ms
67,764 KB
testcase_19 AC 137 ms
55,668 KB
testcase_20 AC 206 ms
64,736 KB
testcase_21 MLE -
testcase_22 AC 222 ms
68,080 KB
testcase_23 AC 194 ms
61,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class No1492 {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		scan.close();
		int[][][] dp = new int[2*N][N+1][N*N+1];
		dp[0][0][0] = 1;
		for (int i=0; i < 2*N-1; i++) {
			for (int j=0; j <= N; j++) {
				for (int k=0; k <= N*N; k++) {
					if (k+j <= N*N && i+1-j <= N) {
						dp[i+1][j][k+j] = (dp[i+1][j][k+j] +dp[i][j][k]) % M;
					}
					if (i-j+1 >= j+1 && j+1 <= N) {
						dp[i+1][j+1][k] = (dp[i+1][j+1][k] + dp[i][j][k]) % M;
					}
				}
			}
		}
		for (int i=0; i <= N*N; i++) {
			System.out.println(dp[2*N-1][N][i]);
		}
	}

}
0