結果

問題 No.1171 Runs in Subsequences
ユーザー NoneNone
提出日時 2021-04-13 23:30:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 337 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 152,040 KB
最終ジャッジ日時 2023-09-12 13:59:49
合計ジャッジ時間 4,675 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
150,612 KB
testcase_01 AC 123 ms
150,780 KB
testcase_02 AC 126 ms
150,660 KB
testcase_03 AC 124 ms
150,696 KB
testcase_04 AC 124 ms
150,680 KB
testcase_05 AC 124 ms
150,748 KB
testcase_06 AC 124 ms
150,756 KB
testcase_07 AC 123 ms
151,044 KB
testcase_08 AC 123 ms
150,744 KB
testcase_09 AC 124 ms
150,756 KB
testcase_10 AC 129 ms
151,276 KB
testcase_11 AC 128 ms
151,196 KB
testcase_12 AC 128 ms
151,300 KB
testcase_13 AC 126 ms
151,156 KB
testcase_14 AC 127 ms
151,276 KB
testcase_15 AC 196 ms
151,900 KB
testcase_16 AC 196 ms
151,672 KB
testcase_17 AC 199 ms
151,820 KB
testcase_18 AC 198 ms
151,616 KB
testcase_19 AC 195 ms
151,748 KB
testcase_20 AC 194 ms
152,040 KB
testcase_21 AC 198 ms
151,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD=10**9+7
p=1
P=[]
for _ in range(10**6+2):
    P.append(p)
    p*=2
    p%=MOD

S=input().rstrip()

dp=0
cnt=[0]*26

for i,s in enumerate(S):
    j=ord(s)-ord("a")
    dp*=2
    dp+=P[i]-cnt[j]
    dp%=MOD
    cnt[j]+=cnt[j]
    for k in range(26):
        if k!=j:
            cnt[j]+=cnt[k]
    cnt[j]+=1
    cnt[j]%=MOD

print(dp)
0