結果

問題 No.792 真理関数をつくろう
ユーザー m1025o1184tm1025o1184t
提出日時 2019-10-14 01:37:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 850 bytes
コンパイル時間 1,729 ms
コンパイル使用メモリ 176,468 KB
実行使用メモリ 7,784 KB
最終ジャッジ日時 2024-05-10 03:28:42
合計ジャッジ時間 3,009 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<string> S = {"A="};
	int h = 0;
	rep(i, pow(2,n)) {
		vector<int> q(n);
		rep(j, n) {
			cin >> q[j];
		}
		int r; cin >> r;
		if (r == 1) {
			rep(j, n) {
				if(j == 0)S.push_back( "(");
				int e = j + 1;
				string f = to_string(e);
				if (q[j] == 1) S.push_back("P_" + f);
				else S.push_back("¬P_" + f );
				if (j == n - 1) S.push_back(")");
				else S.push_back("∧");
				if (S[S.size()-1] == ")") S.push_back("∨");
			}
			h++;
		}
	}
	while(S.at(S.size() - 1) == "∨") S.pop_back();
	if (h == pow(2, n)) cout << "⊤" << endl;
	else if (h == 0) cout << "⊥" << endl;
	else {
		rep(i, S.size()) cout << S[i];
		cout << endl;
	}
	return 0;
}
0