結果
| 問題 |
No.1171 Runs in Subsequences
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-14 22:55:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 719 ms / 2,000 ms |
| コード長 | 424 bytes |
| コンパイル時間 | 495 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 256,768 KB |
| 最終ジャッジ日時 | 2024-10-10 16:15:02 |
| 合計ジャッジ時間 | 6,709 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 |
ソースコード
import sys
input = sys.stdin.readline
from collections import *
S = input()[:-1]
N = len(S)
sub_acc = [[0] for _ in range(26)]
MOD = 10**9+7
for i in range(N):
for j in range(26):
sub_acc[j].append((sub_acc[j][-1]+(pow(2, i, MOD) if ord(S[i])-ord('a')==j else 0))%MOD)
ans = 0
for i in range(N):
ans += (pow(2, i, MOD)-sub_acc[ord(S[i])-ord('a')][i])*pow(2, N-1-i, MOD)
ans %= MOD
print(ans)