結果

問題 No.1492 01文字列と転倒
ユーザー mkawa2mkawa2
提出日時 2023-02-09 11:12:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,054 ms / 4,000 ms
コード長 1,163 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 87,324 KB
実行使用メモリ 93,076 KB
最終ジャッジ日時 2023-09-20 20:40:18
合計ジャッジ時間 11,622 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,580 KB
testcase_01 AC 68 ms
71,564 KB
testcase_02 AC 1,054 ms
93,076 KB
testcase_03 AC 961 ms
92,420 KB
testcase_04 AC 887 ms
91,416 KB
testcase_05 AC 769 ms
89,584 KB
testcase_06 AC 809 ms
90,504 KB
testcase_07 AC 863 ms
90,992 KB
testcase_08 AC 1,044 ms
93,068 KB
testcase_09 AC 76 ms
76,240 KB
testcase_10 AC 69 ms
71,532 KB
testcase_11 AC 69 ms
71,456 KB
testcase_12 AC 68 ms
71,312 KB
testcase_13 AC 70 ms
71,472 KB
testcase_14 AC 797 ms
90,348 KB
testcase_15 AC 85 ms
76,316 KB
testcase_16 AC 102 ms
76,832 KB
testcase_17 AC 786 ms
90,064 KB
testcase_18 AC 105 ms
76,908 KB
testcase_19 AC 81 ms
76,284 KB
testcase_20 AC 96 ms
76,876 KB
testcase_21 AC 661 ms
88,304 KB
testcase_22 AC 104 ms
76,968 KB
testcase_23 AC 90 ms
76,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

n, m = LI()
dp = [[0]*(n**2+1) for _ in range(n+1)]
ndp = [[0]*(n**2+1) for _ in range(n+1)]
ndp[0][0] = 1

for i in range(n+1):
    for j in range(i, n+1):
        if i == j == 0: continue
        for k in range(n**2+1):
            v = 0
            if j-1 >= i and k-i >= 0: v += ndp[j-1][k-i]
            if i: v += dp[j][k]
            ndp[j][k] = v%m
    dp, ndp = ndp, dp
    # p2D(dp)

for k in range(n**2+1):
    print(dp[n][k])
0