結果

問題 No.1366 交換門松列・梅
ユーザー 👑 箱星箱星
提出日時 2021-08-13 16:34:24
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 323 ms / 1,000 ms
コード長 1,093 bytes
コンパイル時間 12,932 ms
コンパイル使用メモリ 441,260 KB
実行使用メモリ 60,464 KB
最終ジャッジ日時 2024-04-17 10:37:52
合計ジャッジ時間 18,095 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 322 ms
60,244 KB
testcase_01 AC 322 ms
60,284 KB
testcase_02 AC 315 ms
60,036 KB
testcase_03 AC 321 ms
60,180 KB
testcase_04 AC 319 ms
60,464 KB
testcase_05 AC 318 ms
60,196 KB
testcase_06 AC 317 ms
60,028 KB
testcase_07 AC 321 ms
60,172 KB
testcase_08 AC 322 ms
60,260 KB
testcase_09 AC 323 ms
60,260 KB
testcase_10 AC 319 ms
60,328 KB
testcase_11 AC 318 ms
60,164 KB
testcase_12 AC 319 ms
60,312 KB
権限があれば一括ダウンロードができます

ソースコード

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.maxOrNull()!! || a[1] == a.minOrNull()!!)
}

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