結果

問題 No.154 市バス
ユーザー rutilicusrutilicus
提出日時 2020-12-17 18:51:31
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 825 bytes
コンパイル時間 14,443 ms
コンパイル使用メモリ 434,416 KB
実行使用メモリ 61,888 KB
最終ジャッジ日時 2023-10-21 07:04:03
合計ジャッジ時間 19,016 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 581 ms
61,748 KB
testcase_01 AC 583 ms
61,748 KB
testcase_02 AC 587 ms
61,748 KB
testcase_03 AC 591 ms
61,752 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 311 ms
54,164 KB
testcase_07 AC 567 ms
61,736 KB
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:27:17: warning: 'appendln(String?): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
        builder.appendln(if (ok && !lastWhite && gCnt == 0) "possible" else "impossible")
                ^

ソースコード

diff #

fun main() {
    val builder = StringBuilder()

    val t = readInputLine().toInt()

    repeat(t) {
        var ok = true
        var gCnt = 0
        var lastWhite = false
        readInputLine().forEach {
            when(it) {
                'G' -> {
                    gCnt++
                    lastWhite = false
                }
                'R' -> {
                    if (gCnt <= 0) {
                        ok = false
                    } else {
                        gCnt--
                    }
                    lastWhite = false
                }
                else -> lastWhite = true
            }
        }
        builder.appendln(if (ok && !lastWhite && gCnt == 0) "possible" else "impossible")
    }

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
0