結果

問題 No.1694 ZerOne
ユーザー 👑 tamatotamato
提出日時 2021-10-01 22:22:09
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 763 ms / 2,000 ms
コード長 844 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 87,532 KB
実行使用メモリ 77,952 KB
最終ジャッジ日時 2023-09-26 18:08:27
合計ジャッジ時間 9,740 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
75,964 KB
testcase_01 AC 78 ms
76,264 KB
testcase_02 AC 79 ms
76,080 KB
testcase_03 AC 308 ms
77,524 KB
testcase_04 AC 90 ms
76,708 KB
testcase_05 AC 128 ms
76,344 KB
testcase_06 AC 76 ms
75,904 KB
testcase_07 AC 115 ms
76,344 KB
testcase_08 AC 150 ms
76,724 KB
testcase_09 AC 319 ms
77,664 KB
testcase_10 AC 106 ms
76,328 KB
testcase_11 AC 79 ms
75,960 KB
testcase_12 AC 79 ms
76,084 KB
testcase_13 AC 173 ms
76,740 KB
testcase_14 AC 304 ms
77,768 KB
testcase_15 AC 130 ms
76,840 KB
testcase_16 AC 125 ms
76,868 KB
testcase_17 AC 94 ms
76,724 KB
testcase_18 AC 73 ms
71,732 KB
testcase_19 AC 73 ms
71,492 KB
testcase_20 AC 75 ms
71,348 KB
testcase_21 AC 763 ms
77,952 KB
testcase_22 AC 100 ms
76,484 KB
testcase_23 AC 752 ms
77,656 KB
testcase_24 AC 430 ms
77,912 KB
testcase_25 AC 431 ms
77,744 KB
testcase_26 AC 111 ms
76,548 KB
testcase_27 AC 649 ms
77,788 KB
testcase_28 AC 256 ms
77,464 KB
testcase_29 AC 263 ms
77,452 KB
testcase_30 AC 297 ms
77,504 KB
testcase_31 AC 369 ms
77,676 KB
testcase_32 AC 404 ms
77,708 KB
testcase_33 AC 412 ms
77,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    N = len(S)
    M = 225
    X = []
    for i in range(N):
        if S[i] == "1":
            X.append(i+1)

    dp = [[0] * (M * 2 + 1) for _ in range(N+1)]
    dp[0][0] = 1
    for x in X:
        dp_new = [[0] * (M * 2 + 1) for _ in range(N + 1)]
        for j_prev in range(N+1):
            for j_new in range(j_prev + 1, N+1):
                for balance in range(-M, M+1):
                    balance_new = balance + (j_new - x)
                    if -M <= balance_new <= M:
                        dp_new[j_new][balance_new] = dp_new[j_new][balance_new] + dp[j_prev][balance]
        dp = dp_new
    ans = 0
    for j in range(N+1):
        ans += dp[j][0]
    print(ans)


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