結果
問題 |
No.792 真理関数をつくろう
|
ユーザー |
![]() |
提出日時 | 2019-02-24 17:38:38 |
言語 | Go (1.23.4) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,614 bytes |
コンパイル時間 | 16,082 ms |
コンパイル使用メモリ | 238,784 KB |
実行使用メモリ | 8,012 KB |
最終ジャッジ日時 | 2024-12-23 07:36:38 |
合計ジャッジ時間 | 17,273 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 TLE * 1 |
ソースコード
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func pow(a, b int) int { res := 1 for range make([]struct{}, b) { res *= a } return res } func main() { io := newIo() defer io.flush() n := io.nextInt() flg := false ans := "" for range make([]struct{}, pow(2, n)) { q := make([]int, n) for j := range q { q[j] = io.nextInt() } r := io.nextInt() if r == 1 { if ans != "" { ans += "∨" } ans += "(" for j, v := range q { if j != 0 { ans += "∧" } if v == 0 { ans += "¬" } ans += "P_" + strconv.Itoa(j+1) } ans += ")" } else { flg = true } } if ans == "" { ans = "⊥" } else if !flg { ans = "⊤" } io.printf("A=%s\n", ans) } type _io struct { reader *bufio.Reader writer *bufio.Writer tokens []string nextToken int } func newIo() *_io { return &_io{ reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout), } } func (_io *_io) flush() { _ = _io.writer.Flush() } func (_io *_io) nextLine() string { var buffer []byte for { line, isPrefix, _ := _io.reader.ReadLine() buffer = append(buffer, line...) if !isPrefix { break } } return string(buffer) } func (_io *_io) next() string { for _io.nextToken >= len(_io.tokens) { line := _io.nextLine() _io.tokens = strings.Fields(line) _io.nextToken = 0 } r := _io.tokens[_io.nextToken] _io.nextToken++ return r } func (_io *_io) nextInt() int { i, _ := strconv.Atoi(_io.next()) return i } func (_io *_io) printf(format string, a ...interface{}) { fmt.Fprintf(_io.writer, format, a...) }