結果
問題 |
No.548 国士無双
|
ユーザー |
|
提出日時 | 2018-03-30 06:10:38 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 295 ms / 2,000 ms |
コード長 | 1,201 bytes |
コンパイル時間 | 12,234 ms |
コンパイル使用メモリ | 431,204 KB |
実行使用メモリ | 49,976 KB |
最終ジャッジ日時 | 2024-11-20 15:12:47 |
合計ジャッジ時間 | 20,660 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
コンパイルメッセージ
Main.kt:5:10: warning: parameter 'args' is never used fun main(args: Array<String>) { ^ Main.kt:14:19: warning: 'toInt(): Int' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead. if (s.toInt() in 97..109) { ^ Main.kt:15:28: warning: 'toInt(): Int' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead. charList[s.toInt() - 97]++ ^
ソースコード
package net.ipipip0129.kotlin.yukicoder import kotlin.math.sign fun main(args: Array<String>) { val lineData = readLine() val errorOutput = "Impossible" var charList = Array(13, {0}) // a-m以外お断り lineData!!.forEach { s -> run { if (s.toInt() in 97..109) { charList[s.toInt() - 97]++ } else { println(errorOutput) return } } } // 三つ以上の牌がないか if (charList.any { i -> 3 <= i }) { println(errorOutput) return } // ペアの数が0なら存在する牌を変えす // ペアの数が1なら存在しない牌を返す // ペアの数が2以上なら成立しないのでエラー when (charList.filter { i -> i == 2 }.size) { 0 -> { charList.forEachIndexed { index, i -> if (i == 1) println((index + 97).toChar())} } 1 -> { charList.forEachIndexed { index, i -> if (i == 0) println((index + 97).toChar())} } else -> { println(errorOutput) return } } }