結果

問題 No.548 国士無双
ユーザー Pump0129Pump0129
提出日時 2018-03-30 06:10:38
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 288 ms / 2,000 ms
コード長 1,201 bytes
コンパイル時間 11,241 ms
コンパイル使用メモリ 438,724 KB
実行使用メモリ 54,280 KB
最終ジャッジ日時 2024-04-30 17:55:13
合計ジャッジ時間 18,892 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 274 ms
54,280 KB
testcase_01 AC 268 ms
54,276 KB
testcase_02 AC 266 ms
54,232 KB
testcase_03 AC 273 ms
54,236 KB
testcase_04 AC 278 ms
54,152 KB
testcase_05 AC 268 ms
54,092 KB
testcase_06 AC 271 ms
54,244 KB
testcase_07 AC 272 ms
54,196 KB
testcase_08 AC 276 ms
54,160 KB
testcase_09 AC 274 ms
54,280 KB
testcase_10 AC 271 ms
54,264 KB
testcase_11 AC 274 ms
53,996 KB
testcase_12 AC 286 ms
54,112 KB
testcase_13 AC 288 ms
54,200 KB
testcase_14 AC 271 ms
54,132 KB
testcase_15 AC 276 ms
54,232 KB
testcase_16 AC 273 ms
54,156 KB
testcase_17 AC 270 ms
54,128 KB
testcase_18 AC 267 ms
54,160 KB
testcase_19 AC 272 ms
54,276 KB
testcase_20 AC 270 ms
54,136 KB
testcase_21 AC 274 ms
54,088 KB
testcase_22 AC 276 ms
54,036 KB
testcase_23 AC 267 ms
54,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]++
                           ^

ソースコード

diff #

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
        }
    }

}
0