結果

問題 No.2090 否定論理積と充足可能性
ユーザー eve__fuyuki
提出日時 2024-05-05 14:30:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 2,050 ms
コンパイル使用メモリ 198,124 KB
最終ジャッジ日時 2025-02-21 11:02:21
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}
bool nand(bool a, bool b) { return !(a && b); }
bool f(vector<bool> a) {
    return nand(nand(nand(a[0], a[1]), a[2]), nand(nand(a[3], a[4]), a[5]));
}
int main() {
    fast_io();
    string a[6];
    for (int i = 0; i < 6; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < 64; i++) {
        vector<bool> b(6);
        for (int j = 0; j < 6; j++) {
            b[j] = (i >> j) & 1;
        }
        if (f(b)) {
            bool is_ok = true;
            for (int j = 0; j < 6; j++) {
                for (int k = j + 1; k < 6; k++) {
                    if (b[j] != b[k] && a[j] == a[k]) {
                        is_ok = false;
                        break;
                    }
                }
            }
            if (is_ok) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}
0