結果

問題 No.2090 否定論理積と充足可能性
ユーザー 👑 箱
提出日時 2022-09-30 22:36:53
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 278 ms / 2,000 ms
コード長 1,598 bytes
コンパイル時間 13,027 ms
コンパイル使用メモリ 421,712 KB
実行使用メモリ 55,320 KB
最終ジャッジ日時 2023-08-24 16:13:38
合計ジャッジ時間 20,243 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 274 ms
53,120 KB
testcase_01 AC 274 ms
53,416 KB
testcase_02 AC 276 ms
54,916 KB
testcase_03 AC 274 ms
54,956 KB
testcase_04 AC 274 ms
53,060 KB
testcase_05 AC 275 ms
52,948 KB
testcase_06 AC 273 ms
55,044 KB
testcase_07 AC 274 ms
54,960 KB
testcase_08 AC 272 ms
55,060 KB
testcase_09 AC 276 ms
54,940 KB
testcase_10 AC 274 ms
53,204 KB
testcase_11 AC 274 ms
55,052 KB
testcase_12 AC 273 ms
55,132 KB
testcase_13 AC 273 ms
54,900 KB
testcase_14 AC 273 ms
53,180 KB
testcase_15 AC 278 ms
53,052 KB
testcase_16 AC 274 ms
53,068 KB
testcase_17 AC 272 ms
54,884 KB
testcase_18 AC 272 ms
53,160 KB
testcase_19 AC 276 ms
55,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val s = nextLine().split(" ")
    val num = Array(6) { 0 }
    loop@for (i in 0 until 6) {
        for (j in 0 until i) {
            if (s[i] == s[j]) {
                num[i] = num[j]
                continue@loop
            }
        }
        num[i] = i
    }
    for (bits in 0 until 1.shl(6)) {
        val b = Array(6) { false }
        for (i in 0 until 6) {
            if ((bits.shr(i) and 1) != 0) {
                b[i] = true
            }
        }
        if (f(b[num[0]], b[num[1]], b[num[2]], b[num[3]], b[num[4]], b[num[5]])) {
            println("YES")
            return
        }
    }
    println("NO")
}

fun f(a0: Boolean, a1: Boolean, a2: Boolean, a3: Boolean, a4: Boolean, a5: Boolean) = ((a0 nand a1) nand a2) nand ((a3 nand a4) nand a5)

private infix fun Boolean.nand(a: Boolean) = !(this && a)

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", abs(1L.shl(26)))
        .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
        .apply { start() }.join()
}

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