結果
問題 | No.154 市バス |
ユーザー | バカらっく |
提出日時 | 2019-11-05 02:02:50 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 980 ms / 2,000 ms |
コード長 | 967 bytes |
コンパイル時間 | 16,736 ms |
コンパイル使用メモリ | 418,644 KB |
実行使用メモリ | 61,152 KB |
最終ジャッジ日時 | 2023-10-13 02:14:13 |
合計ジャッジ時間 | 23,481 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 918 ms
60,788 KB |
testcase_01 | AC | 907 ms
61,116 KB |
testcase_02 | AC | 898 ms
60,904 KB |
testcase_03 | AC | 975 ms
60,544 KB |
testcase_04 | AC | 980 ms
60,752 KB |
testcase_05 | AC | 302 ms
52,764 KB |
testcase_06 | AC | 300 ms
52,868 KB |
testcase_07 | AC | 969 ms
61,152 KB |
testcase_08 | AC | 307 ms
53,268 KB |
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'arr' is never used fun main(arr:Array<String>) { ^
ソースコード
fun main(arr:Array<String>) { val inputCount = readLine()!!.toInt() (1..inputCount).map { if(isValid(readLine()!!)) "possible" else "impossible" }.forEach { println(it) } } fun isValid(inpt:String):Boolean { val log = inpt.reversed() val line = mutableListOf<Char>() for(i in log) { if(i == 'R') { line.add(i) } else if(i == 'G') { val idx = line.indexOfFirst { it == 'R' } if(idx < 0) { return false } line[idx] = 'G' } else if(i == 'W') { val idx = line.indexOfFirst { it == 'G' } if(idx < 0) { val idx2 = line.indexOfFirst { it == 'W' } if(idx2 < 0) { return false } else { line[idx2] = 'W' } } else { line[idx] = 'W' } } } return line.all { it == 'W' } }