結果

問題 No.792 真理関数をつくろう
ユーザー yusukeyusuke
提出日時 2018-08-09 23:52:04
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,495 bytes
コンパイル時間 789 ms
コンパイル使用メモリ 110,456 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-03 20:52:23
合計ジャッジ時間 2,844 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

void main() {
	auto N = ri;
	string res = "A=";
	bool isbottom = true;
	bool istop = true;
	foreach(_; 0..2^^N) {
		auto arr = readAs!(int[]).map!(i => i == 1);
		if(arr.back) {
			isbottom = false;
			res ~= "(";
			foreach(i, v; arr[0..$-1].array) {
				if(!v) res ~= "¬";
				res ~= "P_" ~ (i+1).to!string;
				if(i != arr.length-2) res ~= "∧";
			}
			res ~= ")∨";
		} else istop = false;
	}
	if(isbottom) writeln("A=⊥");
	else if(istop) writeln("A=⊤");
	else {
		res.popBack;
		res.writeln;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}
0