結果
| 問題 | No.792 真理関数をつくろう | 
| コンテスト | |
| ユーザー |  emthrm | 
| 提出日時 | 2019-02-23 02:48:12 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 9 ms / 2,000 ms | 
| コード長 | 1,528 bytes | 
| コンパイル時間 | 1,041 ms | 
| コンパイル使用メモリ | 126,832 KB | 
| 最終ジャッジ日時 | 2025-01-06 21:42:57 | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 22 | 
ソースコード
#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;
}
            
            
            
        