結果

問題 No.792 真理関数をつくろう
ユーザー CuriousFairy315
提出日時 2019-02-22 21:43:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 957 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 71,596 KB
最終ジャッジ日時 2025-01-06 21:39:04
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<sstream>
using namespace std; // 575

int main() {
	int N, Q, R;
	cin >> N;
	stringstream S;
	bool showOr = false, isAllTrue = true, isAllFalse = true;
	for (int i = 0, l = 1 << N;i < l;++ i) {
		stringstream T;
		T << "(";
		for (int j = 0;j < N;++ j) {
			if (j != 0) T << "∧";
			cin >> Q;
			if (Q == 0) T << "¬";
			T << "P_" << j + 1;
		}
		cin >> R;
		isAllTrue &= R == 1;
		isAllFalse &= R == 0;
		if (R == 1) {
			if (showOr) S << "∨";
			S << T.str() << ")";
			showOr = true;
		}
	}
	cout << "A=";
	if (isAllTrue) cout << "⊤";
	else if (isAllFalse) cout << "⊥";
	else cout << S.str();
	cout << endl;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

あの、環境依存文字
*/
0