結果

問題 No.1492 01文字列と転倒
ユーザー sgswsgsw
提出日時 2021-05-03 14:27:30
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,480 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 113,408 KB
最終ジャッジ日時 2023-09-29 10:25:59
合計ジャッジ時間 23,958 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 293 ms
109,492 KB
testcase_01 AC 470 ms
109,820 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 729 ms
109,976 KB
testcase_10 AC 295 ms
110,016 KB
testcase_11 AC 551 ms
109,452 KB
testcase_12 AC 556 ms
110,156 KB
testcase_13 AC 380 ms
109,872 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def input():
    return sys.stdin.readline().rstrip()

"""
Do not get stuck on a problem for more than 20 minutes
Just check the editorial :)
There should be something else to do insead
"""
MAXN = 100
MAXINV = MAXN * MAXN
DP0 = [[0]*(MAXINV + 10) for i in range(2 * MAXN + 10)]
DP1 = [[0]*(MAXINV + 10) for i in range(2 * MAXN + 10)]

def slv():
    #DP[i][dif][inverse]
    N,M = map(int,input().split())
    DP0[0][0] = 1
    for i in range(2 * N):
        if i % 2 == 0:
            #DP0 -> DP1
            for dif in range(MAXN + 1):
                for inv in range(MAXINV + 1):
                    DP1[dif][inv] = 0
            
            for dif in range(MAXN + 1):
                for inv in range(MAXINV + 1):
                    v = DP0[dif][inv] % M
                    DP1[dif + 1][inv + (i - dif) // 2] += v
                    DP1[dif - 1][inv] += v


        else:
            #DP1 -> DP0
            for dif in range(MAXN + 1):
                for inv in range(MAXINV + 1):
                    DP0[dif][inv] = 0
            
            for dif in range(MAXN + 1):
                for inv in range(MAXINV + 1):
                    v = DP1[dif][inv] % M
                    DP0[dif + 1][inv + (i - dif) // 2] += v
                    DP0[dif - 1][inv] += v
    ans = DP0[0]
    for i in range(N * N + 1):
        print(ans[i])
    return 

def main():
    t = 1
    for i in range(t):
        slv()
    return 


if __name__ == "__main__":
    main()
0