結果

問題 No.1171 Runs in Subsequences
ユーザー yudedakoyudedako
提出日時 2020-08-28 16:09:39
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 13,650 ms
コンパイル使用メモリ 413,904 KB
実行使用メモリ 55,000 KB
最終ジャッジ日時 2023-08-08 19:45:10
合計ジャッジ時間 21,567 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 255 ms
52,636 KB
testcase_01 AC 244 ms
52,892 KB
testcase_02 AC 248 ms
52,600 KB
testcase_03 AC 276 ms
52,652 KB
testcase_04 AC 242 ms
52,844 KB
testcase_05 AC 244 ms
52,820 KB
testcase_06 AC 249 ms
53,008 KB
testcase_07 AC 271 ms
52,664 KB
testcase_08 AC 243 ms
52,916 KB
testcase_09 AC 235 ms
52,592 KB
testcase_10 AC 244 ms
52,696 KB
testcase_11 AC 244 ms
52,772 KB
testcase_12 AC 253 ms
52,828 KB
testcase_13 AC 254 ms
52,692 KB
testcase_14 AC 258 ms
53,000 KB
testcase_15 AC 340 ms
54,828 KB
testcase_16 AC 342 ms
54,860 KB
testcase_17 AC 334 ms
54,780 KB
testcase_18 AC 330 ms
54,760 KB
testcase_19 AC 337 ms
54,708 KB
testcase_20 AC 338 ms
55,000 KB
testcase_21 AC 334 ms
54,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fun main() {
    val mod = 1000000007L
    val str = readLine()!!.trim()
    val patternEndWith = LongArray(26){0L}
    var allPattern = 1L
    var allCount = 0L
    for (c in str) {
        val increasePattern = allPattern - patternEndWith[c - 'a'] + mod
        patternEndWith[c - 'a'] = (patternEndWith[c - 'a'] + allPattern) % mod
        allPattern = (allPattern shl 1) % mod
        allCount = ((allCount shl 1) + increasePattern) % mod
    }
    println(allCount)
}
0