結果

問題 No.380 悪の台本
ユーザー firiexpfiriexp
提出日時 2019-08-21 17:39:48
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 897 ms / 1,000 ms
コード長 961 bytes
コンパイル時間 12,995 ms
コンパイル使用メモリ 420,804 KB
実行使用メモリ 61,924 KB
最終ジャッジ日時 2023-08-13 02:50:04
合計ジャッジ時間 18,557 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 288 ms
52,948 KB
testcase_01 AC 294 ms
52,836 KB
testcase_02 AC 288 ms
52,988 KB
testcase_03 AC 288 ms
52,696 KB
testcase_04 AC 485 ms
57,348 KB
testcase_05 AC 521 ms
59,488 KB
testcase_06 AC 521 ms
59,456 KB
testcase_07 AC 897 ms
61,924 KB
testcase_08 AC 411 ms
55,016 KB
testcase_09 AC 475 ms
55,616 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:4:18: warning: 'toLowerCase(): String' is deprecated. Use lowercase() instead.
    var s = line.toLowerCase();
                 ^
Main.kt:25:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

fun solve(line: String): Boolean {
    if(line.isEmpty()) return false
    var s = line.toLowerCase();
    for (i in 0 until 3){
        if(s.isEmpty()) return false
        if(!s.last().isLetterOrDigit()) s = s.dropLast(1)
    }
    if(s.isEmpty()) return false
    if (line.startsWith("digi ")){

        return s.endsWith("nyo") && s != "digi"
    }else if (line.startsWith("petit ")){
        return s.endsWith("nyu") && s != "nyu"
    }else if(line.startsWith("rabi ")){
        return s.length >= 5 && s.subSequence(5, s.length).any { it.isLetterOrDigit()}
    }else if(line.startsWith("gema ")){
        return s.endsWith("gema") && s != "gema"
    }else if(line.startsWith("piyo "))
        return s.endsWith("pyo") && s != "pyo"
    else return false
}


fun main(args: Array<String>) {
    var s : String?
    do {
        s = readLine()
        if(s == null) break
        println( if (solve(s)) "CORRECT (maybe)" else "WRONG!")
    } while (true)
}
0