結果

問題 No.1492 01文字列と転倒
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-04-30 21:52:33
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 971 ms / 4,000 ms
コード長 568 bytes
コンパイル時間 1,066 ms
コンパイル使用メモリ 86,768 KB
実行使用メモリ 276,420 KB
最終ジャッジ日時 2023-09-26 05:53:58
合計ジャッジ時間 10,572 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,508 KB
testcase_01 AC 69 ms
71,512 KB
testcase_02 AC 971 ms
275,660 KB
testcase_03 AC 903 ms
276,420 KB
testcase_04 AC 843 ms
271,516 KB
testcase_05 AC 717 ms
230,252 KB
testcase_06 AC 743 ms
243,048 KB
testcase_07 AC 813 ms
272,412 KB
testcase_08 AC 967 ms
275,436 KB
testcase_09 AC 73 ms
76,080 KB
testcase_10 AC 68 ms
71,112 KB
testcase_11 AC 68 ms
71,216 KB
testcase_12 AC 67 ms
71,268 KB
testcase_13 AC 66 ms
71,420 KB
testcase_14 AC 742 ms
243,096 KB
testcase_15 AC 86 ms
76,760 KB
testcase_16 AC 98 ms
77,580 KB
testcase_17 AC 712 ms
230,296 KB
testcase_18 AC 99 ms
77,532 KB
testcase_19 AC 81 ms
76,532 KB
testcase_20 AC 93 ms
77,584 KB
testcase_21 AC 599 ms
191,776 KB
testcase_22 AC 101 ms
77,668 KB
testcase_23 AC 90 ms
76,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,mod = map(int,input().split())
M = n*(n-1)//2
dp = [[0]*(M+1) for i in range(n+1)]
dp[0][0] = 1

for i in range(2*n):
    ndp = [[0]*(M+1) for j in range(n+1)]
    for j in range(n+1):
        for k in range(M+1):
            if dp[j][k] == 0:
                continue
            if j != n:
                ndp[j+1][k] += dp[j][k]
                ndp[j+1][k] %= mod
            if i-j >= j:
                continue
            ndp[j][k+n-j] += dp[j][k]
            ndp[j][k+n-j] %= mod
    dp = ndp
for i in dp[n]:
    print(i)
for i in range(n**2-M):
    print(0)
0