結果

問題 No.792 真理関数をつくろう
ユーザー MaboyMaboy
提出日時 2021-06-24 17:21:25
言語 Swift
(5.10.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 625 bytes
コンパイル時間 12,034 ms
コンパイル使用メモリ 178,252 KB
実行使用メモリ 14,456 KB
最終ジャッジ日時 2023-09-07 13:25:22
合計ジャッジ時間 15,104 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
13,668 KB
testcase_01 AC 10 ms
13,660 KB
testcase_02 AC 6 ms
13,708 KB
testcase_03 AC 14 ms
13,696 KB
testcase_04 AC 6 ms
13,600 KB
testcase_05 AC 14 ms
13,764 KB
testcase_06 AC 46 ms
14,456 KB
testcase_07 AC 8 ms
14,128 KB
testcase_08 AC 6 ms
13,700 KB
testcase_09 AC 6 ms
13,504 KB
testcase_10 AC 6 ms
13,576 KB
testcase_11 AC 5 ms
13,764 KB
testcase_12 AC 6 ms
13,580 KB
testcase_13 AC 5 ms
13,504 KB
testcase_14 AC 6 ms
13,532 KB
testcase_15 AC 6 ms
13,428 KB
testcase_16 AC 25 ms
14,060 KB
testcase_17 AC 6 ms
13,668 KB
testcase_18 AC 6 ms
13,412 KB
testcase_19 AC 6 ms
14,088 KB
testcase_20 AC 38 ms
13,548 KB
testcase_21 AC 56 ms
14,420 KB
testcase_22 AC 5 ms
13,412 KB
testcase_23 AC 6 ms
13,708 KB
testcase_24 AC 6 ms
13,712 KB
testcase_25 AC 6 ms
14,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import Foundation
let n = Int(readLine()!)!
var res = [String]()
var cnt = 0
for _ in 0..<Int(pow(2,Double(n))){
    let f = readLine()!.split(separator: " ").map{Int($0)!}
    if f.last == 1{
        cnt += 1
        var tmp = [String]()
        for j in 0..<n{
            if f[j] == 1{
                tmp += ["P_" + String(j + 1)]
            }else{
                tmp += ["¬P_" + String(j + 1)]
            }
        }
        res += ["(" + tmp.joined(separator: "∧") + ")"]
    }
}
if cnt == 0{
    res = ["⊥"]
}else if cnt == Int(pow(2,Double(n))){
    res = ["⊤"]
}
print("A=" + res.joined(separator: "∨"))
0