結果

問題 No.792 真理関数をつくろう
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2019-02-24 18:12:48
言語 Go
(1.22.1)
結果
AC  
実行時間 408 ms / 2,000 ms
コード長 996 bytes
コンパイル時間 10,952 ms
コンパイル使用メモリ 211,784 KB
実行使用メモリ 5,688 KB
最終ジャッジ日時 2023-08-24 22:50:15
合計ジャッジ時間 13,299 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,332 KB
testcase_01 AC 29 ms
4,360 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 60 ms
4,356 KB
testcase_04 AC 2 ms
4,364 KB
testcase_05 AC 60 ms
4,360 KB
testcase_06 AC 273 ms
5,684 KB
testcase_07 AC 13 ms
4,356 KB
testcase_08 AC 1 ms
4,364 KB
testcase_09 AC 2 ms
4,360 KB
testcase_10 AC 2 ms
4,360 KB
testcase_11 AC 2 ms
4,364 KB
testcase_12 AC 2 ms
4,360 KB
testcase_13 AC 2 ms
4,360 KB
testcase_14 AC 1 ms
4,360 KB
testcase_15 AC 6 ms
4,360 KB
testcase_16 AC 126 ms
4,356 KB
testcase_17 AC 4 ms
4,360 KB
testcase_18 AC 2 ms
4,360 KB
testcase_19 AC 2 ms
4,360 KB
testcase_20 AC 143 ms
5,688 KB
testcase_21 AC 408 ms
5,684 KB
testcase_22 AC 2 ms
4,360 KB
testcase_23 AC 1 ms
4,360 KB
testcase_24 AC 2 ms
4,360 KB
testcase_25 AC 2 ms
4,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import "fmt"

func pow(a, b int) int {
	res := 1
	for range make([]struct{}, b) {
		res *= a
	}
	return res
}

func main() {
	var n int
	fmt.Scan(&n)

	ans := make([][]bool, pow(2, n))

	var notAllOkFlg, notAllNgFlg bool
	for i := range ans {
		q := make([]int8, n)
		for j := range q {
			fmt.Scan(&q[j])
		}
		var r int8
		fmt.Scan(&r)
		if r == 1 {
			ans[i] = make([]bool, n)
			for j, v := range q {
				if v == 1 {
					ans[i][j] = true
				}
			}
			notAllNgFlg = true
		} else {
			notAllOkFlg = true
		}
	}

	fmt.Print("A=")
	if !notAllNgFlg {
		fmt.Println("⊥")
	} else if !notAllOkFlg {
		fmt.Println("⊤")
	} else {
		flg := false
		for i := range ans {
			if ans[i] == nil {
				continue
			}
			if flg {
				fmt.Print("∨")
			}
			fmt.Print("(")
			for j, v := range ans[i] {
				if j != 0 {
					fmt.Print("∧")
				}
				if !v {
					fmt.Print("¬")
				}
				fmt.Print("P_")
				fmt.Print(j + 1)
			}
			fmt.Print(")")
			flg = true
		}
		fmt.Println()
	}

}
0