結果

問題 No.1694 ZerOne
ユーザー shotoyooshotoyoo
提出日時 2021-10-01 22:08:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,330 ms / 2,000 ms
コード長 860 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 82,104 KB
実行使用メモリ 111,312 KB
最終ジャッジ日時 2024-07-19 11:28:35
合計ジャッジ時間 8,495 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))

# list 多重リスト生成
def dlist(*l, fill=None):
    if len(l)==1:
        return [fill]*l[0]
    ll = l[1:]
    return [dlist(*ll, fill=fill) for _ in range(l[0])]
s = list(map(int, input()))
n = len(s)
total = 0
num = 0
for i,c in enumerate(s):
    if c:
        total += i
        num += 1
dp = dlist(total+1, n+1, fill=0)
dp[0][0] = 1
for i in range(num):
    ndp = dlist(total+1, n+1, fill=0)
    for j in range(total+1):
        for p in range(n):
            val = dp[j][p]
            for k in range(p+1, n+1):
                if (k-1)+j > total:
                    break
                ndp[k-1+j][k] += val
    dp = ndp
ans = sum(dp[total])
print(ans)
0