結果

問題 No.548 国士無双
ユーザー Pump0129Pump0129
提出日時 2018-03-30 06:10:38
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 1,201 bytes
コンパイル時間 12,725 ms
コンパイル使用メモリ 419,780 KB
実行使用メモリ 50,776 KB
最終ジャッジ日時 2023-08-12 22:55:08
合計ジャッジ時間 20,979 ms
ジャッジサーバーID
(参考情報)
judge12 / judge8
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 270 ms
50,108 KB
testcase_01 AC 274 ms
50,080 KB
testcase_02 AC 269 ms
49,968 KB
testcase_03 AC 271 ms
50,028 KB
testcase_04 AC 268 ms
50,104 KB
testcase_05 AC 270 ms
49,916 KB
testcase_06 AC 274 ms
50,072 KB
testcase_07 AC 269 ms
50,044 KB
testcase_08 AC 268 ms
50,244 KB
testcase_09 AC 270 ms
50,124 KB
testcase_10 AC 268 ms
50,404 KB
testcase_11 AC 268 ms
50,212 KB
testcase_12 AC 273 ms
50,096 KB
testcase_13 AC 277 ms
50,448 KB
testcase_14 AC 274 ms
50,448 KB
testcase_15 AC 274 ms
50,048 KB
testcase_16 AC 276 ms
50,412 KB
testcase_17 AC 271 ms
50,208 KB
testcase_18 AC 269 ms
50,044 KB
testcase_19 AC 274 ms
50,232 KB
testcase_20 AC 269 ms
50,160 KB
testcase_21 AC 265 ms
50,776 KB
testcase_22 AC 265 ms
50,440 KB
testcase_23 AC 267 ms
50,108 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