結果

問題 No.1171 Runs in Subsequences
ユーザー NoneNone
提出日時 2021-04-13 23:30:12
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 321 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 156,412 KB
最終ジャッジ日時 2023-09-12 13:59:36
合計ジャッジ時間 6,751 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
155,276 KB
testcase_01 AC 124 ms
150,712 KB
testcase_02 AC 125 ms
150,532 KB
testcase_03 AC 125 ms
150,612 KB
testcase_04 AC 124 ms
150,908 KB
testcase_05 AC 123 ms
150,644 KB
testcase_06 AC 125 ms
150,636 KB
testcase_07 AC 126 ms
150,612 KB
testcase_08 AC 126 ms
150,752 KB
testcase_09 AC 125 ms
150,732 KB
testcase_10 AC 138 ms
151,312 KB
testcase_11 AC 134 ms
151,080 KB
testcase_12 AC 134 ms
151,380 KB
testcase_13 AC 137 ms
151,300 KB
testcase_14 AC 135 ms
151,172 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

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

print(dp)
0