結果

問題 No.1171 Runs in Subsequences
コンテスト
ユーザー aaaaaaaaaa2230
提出日時 2020-08-15 14:40:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 344 ms / 2,000 ms
コード長 289 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 20,436 KB
最終ジャッジ日時 2024-10-10 17:54:24
合計ジャッジ時間 3,565 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

a = [ord(i)-ord("a") for i in input()]
mod = 10**9+7
n = len(a)
count = [0]*26
two = [1]
for i in range(n):
    two.append(two[-1]*2%mod)
ans = 0
for i in range(n):
    ans += ((two[i]-count[a[i]])*two[n-1-i])%mod
    ans %= mod
    count[a[i]] += two[i]
    count[a[i]] %= mod
print(ans)
0