結果

問題 No.792 真理関数をつくろう
ユーザー 👑 emthrmemthrm
提出日時 2019-02-23 02:48:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,528 bytes
コンパイル時間 1,412 ms
コンパイル使用メモリ 128,472 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 05:51:18
合計ジャッジ時間 3,230 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  int beki = 1;
  REP(i, n) beki <<= 1;
  vector<vector<int> > q(beki, vector<int>(n));
  vector<int> r(beki);
  bool top = true, bottom = false;
  int last = -1;
  REP(i, beki) {
    REP(j, n) cin >> q[i][j];
    cin >> r[i];
    top &= r[i];
    bottom |= r[i];
    if (r[i]) last = i;
  }
  if (top) {
    cout << "A=⊤\n";
    return 0;
  }
  if (!bottom) {
    cout << "A=⊥\n";
    return 0;
  }
  string ans = "A=";
  REP(i, beki) if (r[i]) {
    ans += '(';
    REP(j, n) {
      if (!q[i][j]) ans += "¬";
      if (j == n - 1) ans += "P_" + to_string(j + 1) + ')';
      else ans += "P_" + to_string(j + 1) + "∧";
    }
    if (i < last) ans += "∨";
  }
  cout << ans << '\n';
  return 0;
}
0