結果

問題 No.1171 Runs in Subsequences
ユーザー KudeKude
提出日時 2020-08-14 22:10:00
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 454 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 82,764 KB
実行使用メモリ 76,828 KB
最終ジャッジ日時 2024-04-18 21:59:33
合計ジャッジ時間 15,781 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,968 KB
testcase_01 AC 36 ms
51,712 KB
testcase_02 AC 37 ms
52,096 KB
testcase_03 AC 39 ms
52,864 KB
testcase_04 AC 36 ms
51,840 KB
testcase_05 AC 38 ms
52,096 KB
testcase_06 AC 37 ms
52,268 KB
testcase_07 AC 39 ms
51,968 KB
testcase_08 AC 37 ms
52,352 KB
testcase_09 AC 35 ms
52,224 KB
testcase_10 AC 50 ms
61,056 KB
testcase_11 AC 50 ms
61,184 KB
testcase_12 AC 51 ms
61,056 KB
testcase_13 AC 50 ms
61,184 KB
testcase_14 AC 50 ms
61,056 KB
testcase_15 AC 1,968 ms
76,484 KB
testcase_16 AC 1,930 ms
76,432 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10**9 + 7

dp = [0] * 27
s = input()
dp[26] = 1
ans = 0
for z, c in enumerate(s):
    x = ord(c) - ord('a')
    ndp = [0] * 27
    for i in range(27):
        if i == x:
            ndp[x] = (ndp[x] + dp[i] * 2) % MOD
        else:
            ndp[x] = (ndp[x] + dp[i]) % MOD
            ndp[i] = (ndp[i] + dp[i]) % MOD
            ans += dp[i] * pow(2, len(s)-1-z, MOD)
            ans %= MOD
    dp = ndp
    #print(dp)
    #print(ans)
print(ans)
0