結果

問題 No.1171 Runs in Subsequences
ユーザー H3PO4H3PO4
提出日時 2021-11-03 08:26:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-04-20 21:54:25
合計ジャッジ時間 3,020 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
51,840 KB
testcase_01 AC 44 ms
52,096 KB
testcase_02 AC 47 ms
51,584 KB
testcase_03 AC 44 ms
52,224 KB
testcase_04 AC 44 ms
51,968 KB
testcase_05 AC 44 ms
51,968 KB
testcase_06 AC 44 ms
52,096 KB
testcase_07 AC 50 ms
51,840 KB
testcase_08 AC 44 ms
52,096 KB
testcase_09 AC 43 ms
52,352 KB
testcase_10 AC 54 ms
60,288 KB
testcase_11 AC 55 ms
60,032 KB
testcase_12 AC 54 ms
60,800 KB
testcase_13 AC 53 ms
60,288 KB
testcase_14 AC 54 ms
60,416 KB
testcase_15 AC 144 ms
76,364 KB
testcase_16 AC 142 ms
76,148 KB
testcase_17 AC 145 ms
76,408 KB
testcase_18 AC 146 ms
76,672 KB
testcase_19 AC 132 ms
70,016 KB
testcase_20 AC 141 ms
76,160 KB
testcase_21 AC 134 ms
76,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

en2asc = lambda s: ord(s) - 97

S = input()
MOD = 10 ** 9 + 7
ct = [0] * 26
run = [0] * 26
p2 = 1
for s in S:
    i = en2asc(s)
    ct[i] += p2
    ct[i] %= MOD
    p2 *= 2
    p2 %= MOD

    run[i] *= 2
    run[i] += 1
    for j in range(26):
        if i == j:
            continue
        run[i] += run[j] + ct[j]
    run[i] %= MOD
print(sum(run) % MOD)
0