結果

問題 No.1694 ZerOne
ユーザー vwxyzvwxyz
提出日時 2023-04-01 02:02:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 81,852 KB
実行使用メモリ 68,460 KB
最終ジャッジ日時 2023-10-24 11:30:30
合計ジャッジ時間 3,719 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,544 KB
testcase_01 AC 36 ms
53,544 KB
testcase_02 AC 36 ms
53,544 KB
testcase_03 AC 55 ms
66,412 KB
testcase_04 AC 37 ms
53,544 KB
testcase_05 AC 50 ms
64,228 KB
testcase_06 AC 37 ms
53,544 KB
testcase_07 AC 47 ms
61,872 KB
testcase_08 AC 50 ms
64,228 KB
testcase_09 AC 54 ms
66,408 KB
testcase_10 AC 45 ms
61,864 KB
testcase_11 AC 37 ms
53,544 KB
testcase_12 AC 37 ms
53,544 KB
testcase_13 AC 50 ms
64,228 KB
testcase_14 AC 53 ms
64,364 KB
testcase_15 AC 50 ms
64,228 KB
testcase_16 AC 48 ms
61,900 KB
testcase_17 AC 38 ms
53,544 KB
testcase_18 AC 37 ms
53,544 KB
testcase_19 AC 36 ms
53,544 KB
testcase_20 AC 39 ms
59,512 KB
testcase_21 AC 40 ms
59,512 KB
testcase_22 AC 45 ms
62,200 KB
testcase_23 AC 48 ms
62,032 KB
testcase_24 AC 58 ms
66,412 KB
testcase_25 AC 59 ms
68,460 KB
testcase_26 AC 45 ms
61,988 KB
testcase_27 AC 48 ms
62,032 KB
testcase_28 AC 40 ms
59,516 KB
testcase_29 AC 58 ms
66,416 KB
testcase_30 AC 54 ms
66,412 KB
testcase_31 AC 58 ms
66,412 KB
testcase_32 AC 58 ms
66,428 KB
testcase_33 AC 58 ms
66,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

S=readline().rstrip()
N=len(S)
cnt0=S.count("0")
cnt1=S.count("1")
inve=sum(1 for i in range(N) for j in range(i+1,N) if S[i]>S[j])
dp=[[[0]*(inve+1) for c1 in range(cnt1+1)] for c0 in range(cnt0+1)]
dp[0][0][0]=1
for c0 in range(cnt0+1):
    for c1 in range(cnt1+1):
        for i in range(inve+1):
            if c0 and 0<=i-c1:
                dp[c0][c1][i]+=dp[c0-1][c1][i-c1]
            if c1:
                dp[c0][c1][i]+=dp[c0][c1-1][i]
ans=dp[cnt0][cnt1][inve]
print(ans)
0