結果

問題 No.792 真理関数をつくろう
ユーザー nadeshinonadeshino
提出日時 2019-02-22 21:54:59
言語 Nim
(2.0.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,442 bytes
コンパイル時間 3,259 ms
コンパイル使用メモリ 69,512 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 12:00:50
合計ジャッジ時間 4,498 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 12 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 16 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 19) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(48, 5) Warning: use `delete(s, first..last)`; delete is deprecated [Deprecated]
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'algorithm' [UnusedImport]
/home/judge/data/code/Main.nim(1, 19) Warning: imported and not used: 'future' [UnusedImport]
/home/judge/data/code/Main.nim(1, 27) Warning: imported and not used: 'hashes' [UnusedImport]

ソースコード

diff #

import algorithm, future, hashes, macros, math, sequtils, sets, strutils, tables, unicode

template readString: string = stdin.readLine
template readStrings: seq[string] = stdin.readLine.split
template readInt: int = stdin.readLine.parseInt
template readInts: seq[int] = readLine(stdin).split(" ").map(parseInt)
template readFloat: float = stdin.readLine.parseFloat
template readFloats: seq[float] = stdin.readLine.split.map(parseFloat)
template times(n: int, body: untyped): untyped = (for _ in 0..<n: body)
proc newSeq2[T](n1, n2: Natural): seq[seq[T]] = newSeqWith(n1, newSeq[T](n2))
proc newSeq3[T](n1, n2, n3: Natural): seq[seq[seq[T]]] = newSeqWith(n1, newSeqWith(n2, newSeq[T](n3)))

macro unpack*(rhs: seq, cnt: static[int]): auto =
  let t = genSym(); result = quote do:(let `t` = `rhs`;())
  for i in 0..<cnt: result[0][1].add(quote do:`t`[`i`])

# -------------------------------------------------- #

var N = readInt
var res = "A="
var cnt = 0
for i in 1..(2 ^ N):
  var QR = @[0] & readInts
  if QR[N + 1] == 1:
    cnt += 1
    res.add("(")
    for j in 1..<N:
      if QR[j] == 0:
        res.add("¬")
      res.add("P_")
      res.add(j.intToStr(1))
      res.add("∧")
    if QR[N] == 0:
      res.add("¬")
    res.add("P_")
    res.add(N.intToStr(1))
    res.add(")∨")

if cnt == 2 ^ N:
  res = "A=⊤"
  echo res
  quit()
if cnt == 0:
  res = "A=⊥"
  echo res
  quit()

res.delete(res.len - 3, res.len - 1)
echo res
0