結果

問題 No.2090 否定論理積と充足可能性
ユーザー H3PO4H3PO4
提出日時 2022-09-30 21:40:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 8,116 KB
最終ジャッジ日時 2023-08-24 15:03:17
合計ジャッジ時間 1,306 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,984 KB
testcase_01 AC 15 ms
7,940 KB
testcase_02 AC 16 ms
8,004 KB
testcase_03 AC 16 ms
8,056 KB
testcase_04 AC 15 ms
8,004 KB
testcase_05 AC 15 ms
7,972 KB
testcase_06 AC 15 ms
7,924 KB
testcase_07 AC 15 ms
8,000 KB
testcase_08 AC 15 ms
7,956 KB
testcase_09 AC 15 ms
7,952 KB
testcase_10 AC 16 ms
7,984 KB
testcase_11 AC 16 ms
7,972 KB
testcase_12 AC 15 ms
8,012 KB
testcase_13 AC 15 ms
7,988 KB
testcase_14 AC 15 ms
7,980 KB
testcase_15 AC 15 ms
8,076 KB
testcase_16 AC 15 ms
8,004 KB
testcase_17 AC 15 ms
8,068 KB
testcase_18 AC 15 ms
8,100 KB
testcase_19 AC 15 ms
8,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

A = input().split()
d = dict()
P = [0] * 6
ct = 0
for i, a in enumerate(A):
    if a in d:
        P[i] = d[a]
    else:
        P[i] = ct
        d[a] = ct
        ct += 1


def nand(x, y):
    return not (x and y)


def solve(P, ct):
    for t in itertools.product((0, 1), repeat=ct):
        if nand(nand(nand(t[P[0]], t[P[1]]), t[P[2]]), nand(nand(t[P[3]], t[P[4]]), t[P[5]])):
            return True
    return False


print("YES" if solve(P, ct) else "NO")
0