結果

問題 No.1492 01文字列と転倒
ユーザー 👑 rin204rin204
提出日時 2022-11-02 16:00:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,409 ms / 4,000 ms
コード長 541 bytes
コンパイル時間 1,793 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 256,448 KB
最終ジャッジ日時 2023-09-24 04:56:51
合計ジャッジ時間 15,263 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
71,184 KB
testcase_01 AC 62 ms
71,096 KB
testcase_02 AC 1,304 ms
256,192 KB
testcase_03 AC 1,287 ms
240,684 KB
testcase_04 AC 1,409 ms
232,588 KB
testcase_05 AC 937 ms
211,428 KB
testcase_06 AC 975 ms
216,912 KB
testcase_07 AC 1,133 ms
223,256 KB
testcase_08 AC 1,288 ms
256,448 KB
testcase_09 AC 66 ms
71,212 KB
testcase_10 AC 62 ms
71,500 KB
testcase_11 AC 62 ms
71,444 KB
testcase_12 AC 60 ms
71,224 KB
testcase_13 AC 61 ms
71,300 KB
testcase_14 AC 961 ms
216,828 KB
testcase_15 AC 79 ms
76,200 KB
testcase_16 AC 101 ms
77,648 KB
testcase_17 AC 914 ms
211,456 KB
testcase_18 AC 98 ms
77,228 KB
testcase_19 AC 75 ms
76,200 KB
testcase_20 AC 91 ms
77,096 KB
testcase_21 AC 954 ms
194,296 KB
testcase_22 AC 105 ms
77,520 KB
testcase_23 AC 96 ms
77,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, MOD = map(int, input().split())

def f(o, z, t):
    return (o * (n + 1) + z) * (n * n + 1) + t

dp = {0:1}
for _ in range(2 * n):
    nex = {}
    for k, v in dp.items():
        t = k % (n * n + 1)
        k //= (n * n + 1)
        z = k % (n + 1)
        o = k // (n + 1)
        if z < n:
            nex[f(o, z + 1, t + o)] = (nex.get(f(o, z + 1, t + o), 0) + v) % MOD
        if o < z:
            nex[f(o + 1, z, t)] = (nex.get(f(o + 1, z, t), 0) + v) % MOD
    dp = nex

for i in range(n * n + 1):
    print(dp.get(f(n, n, i), 0))
0