結果

問題 No.1366 交換門松列・梅
ユーザー 👑 箱
提出日時 2021-02-05 21:53:33
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 342 ms / 1,000 ms
コード長 1,081 bytes
コンパイル時間 14,190 ms
コンパイル使用メモリ 444,036 KB
実行使用メモリ 60,360 KB
最終ジャッジ日時 2024-04-14 09:15:52
合計ジャッジ時間 18,943 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 331 ms
60,176 KB
testcase_01 AC 332 ms
60,256 KB
testcase_02 AC 326 ms
60,012 KB
testcase_03 AC 331 ms
60,296 KB
testcase_04 AC 330 ms
60,220 KB
testcase_05 AC 330 ms
60,332 KB
testcase_06 AC 337 ms
60,048 KB
testcase_07 AC 342 ms
60,184 KB
testcase_08 AC 338 ms
60,360 KB
testcase_09 AC 339 ms
60,260 KB
testcase_10 AC 340 ms
60,308 KB
testcase_11 AC 331 ms
60,352 KB
testcase_12 AC 330 ms
60,308 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:6:54: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Int
    return a.distinct().size == 3 && (a[1] == a.max()!! || a[1] == a.min()!!)
                                                     ^
Main.kt:6:75: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Int
    return a.distinct().size == 3 && (a[1] == a.max()!! || a[1] == a.min()!!)
                                                                          ^

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun isKadomatsu(a: Array<Int>): Boolean {
    return a.distinct().size == 3 && (a[1] == a.max()!! || a[1] == a.min()!!)
}

fun PrintWriter.solve() {
    val a = Array(3) { nextInt() }
    val b = Array(3) { nextInt() }
    for (i in 0 until 3) {
        for (j in 0 until 3) {
            val c = a.copyOf()
            val d = b.copyOf()
            c[i] = b[j]
            d[j] = a[i]
            if (isKadomatsu(c) && isKadomatsu(d)) {
                println("Yes")
                return
            }
        }
    }
    println("No")
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve()
    writer.flush()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()!!
fun nextDouble() = next().toDouble()
// endregion
0