結果

問題 No.1492 01文字列と転倒
ユーザー sgswsgsw
提出日時 2021-05-03 14:28:50
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 1,486 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 94,584 KB
最終ジャッジ日時 2023-09-29 10:27:37
合計ジャッジ時間 6,899 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 269 ms
94,584 KB
testcase_01 AC 433 ms
94,536 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

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 + MAXN + 10) for i in range(MAXN + 10)]
DP1 = [[0]*(MAXINV + MAXN + 10) for i in range(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