結果
問題 | No.2090 否定論理積と充足可能性 |
ユーザー | 箱星 |
提出日時 | 2022-09-30 22:36:53 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 323 ms / 2,000 ms |
コード長 | 1,598 bytes |
コンパイル時間 | 14,349 ms |
コンパイル使用メモリ | 446,836 KB |
実行使用メモリ | 55,188 KB |
最終ジャッジ日時 | 2024-12-23 00:22:24 |
合計ジャッジ時間 | 21,633 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
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