結果

問題 No.2090 否定論理積と充足可能性
ユーザー SSRSSSRS
提出日時 2022-09-30 21:29:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 780 bytes
コンパイル時間 2,635 ms
コンパイル使用メモリ 177,712 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 14:46:13
合計ジャッジ時間 2,979 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int nand(int a, int b){
  return 1 - (a & b);
}
int main(){
  vector<string> A(6);
  for (int i = 0; i < 6; i++){
    cin >> A[i];
  }
  vector<string> A2 = A;
  sort(A2.begin(), A2.end());
  A2.erase(unique(A2.begin(), A2.end()), A2.end());
  int cnt = A2.size();
  vector<int> B(6);
  for (int i = 0; i < 6; i++){
    B[i] = lower_bound(A2.begin(), A2.end(), A[i]) - A2.begin();
  }
  bool ok = false;
  for (int i = 0; i < (1 << cnt); i++){
    vector<int> p(cnt);
    for (int j = 0; j < cnt; j++){
      p[j] = i >> j & 1;
    }
    if (nand(nand(nand(p[B[0]], p[B[1]]), p[B[2]]), nand(nand(p[B[3]], p[B[4]]), p[B[5]]))){
      ok = true;
    }
  }
  if (ok){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
0