結果

問題 No.1492 01文字列と転倒
ユーザー H3PO4H3PO4
提出日時 2021-04-30 22:24:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,941 ms / 4,000 ms
コード長 433 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 45,808 KB
最終ジャッジ日時 2023-09-26 06:34:50
合計ジャッジ時間 30,250 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
29,696 KB
testcase_01 AC 139 ms
29,604 KB
testcase_02 AC 2,941 ms
45,808 KB
testcase_03 AC 2,695 ms
44,712 KB
testcase_04 AC 2,453 ms
43,868 KB
testcase_05 AC 2,089 ms
42,408 KB
testcase_06 AC 2,207 ms
42,696 KB
testcase_07 AC 2,420 ms
43,636 KB
testcase_08 AC 2,914 ms
45,696 KB
testcase_09 AC 139 ms
29,604 KB
testcase_10 AC 137 ms
29,564 KB
testcase_11 AC 135 ms
29,656 KB
testcase_12 AC 137 ms
29,592 KB
testcase_13 AC 135 ms
29,540 KB
testcase_14 AC 2,185 ms
42,720 KB
testcase_15 AC 147 ms
29,712 KB
testcase_16 AC 180 ms
29,984 KB
testcase_17 AC 2,124 ms
42,300 KB
testcase_18 AC 183 ms
30,016 KB
testcase_19 AC 140 ms
29,600 KB
testcase_20 AC 164 ms
30,324 KB
testcase_21 AC 1,782 ms
40,468 KB
testcase_22 AC 176 ms
30,092 KB
testcase_23 AC 155 ms
30,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N, M = map(int, input().split())
dp = np.zeros((N + 1, N ** 2 + 1), dtype=np.int64)
dp[0, 0] = 1
for i in range(2 * N):
    new_dp = np.zeros((N + 1, N ** 2 + 1), dtype=np.int64)
    new_dp[:-1, :] = dp[1:, :]
    for j in range(N):
        if i < j: break
        tmp = (i - j) // 2
        new_dp[j + 1, tmp:] += dp[j, :N ** 2 - tmp + 1]
        new_dp[j + 1, tmp:] %= M
    dp = new_dp
print(*dp[0], sep='\n')
0