結果

問題 No.548 国士無双
コンテスト
ユーザー Pump0129
提出日時 2018-03-30 06:10:38
言語 Kotlin
(2.4.10 + ACL)
コンパイル:
kotlinc -cp /opt/aclib/ac_library.jar _filename_ -include-runtime -d main.jar
実行:
java -cp main.jar:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 73 ms / 2,000 ms
+ 787µs
コード長 1,201 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,928 ms
コンパイル使用メモリ 508,128 KB
実行使用メモリ 45,432 KB
最終ジャッジ日時 2026-09-27 02:04:01
合計ジャッジ時間 11,984 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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