結果
| 問題 |
No.792 真理関数をつくろう
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2019-02-24 19:31:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 1,304 bytes |
| コンパイル時間 | 670 ms |
| コンパイル使用メモリ | 84,412 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 13:21:31 |
| 合計ジャッジ時間 | 1,664 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:44:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
44 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:49:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
49 | for (int j = 0; j < n; j++) scanf("%d", &qs[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:50:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
50 | scanf("%d", rs + i);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 792.cc: No.792 真理関数をつくろう - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 12;
const int NBITS = 1 << MAX_N;
/* typedef */
/* global variables */
int qs[NBITS][MAX_N], rs[NBITS];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
int nbits = 1 << n;
int ro = 0, ra = 1;
for (int i = 0; i < nbits; i++) {
for (int j = 0; j < n; j++) scanf("%d", &qs[i][j]);
scanf("%d", rs + i);
ro |= rs[i];
ra &= rs[i];
//printf("rs[%d]=%d\n", i, rs[i]);
}
//printf("ro=%d, ra=%d\n", ro, ra);
if (ro == 0) puts("A=⊥");
else if (ra == 1) puts("A=⊤");
else {
printf("A=");
for (int i = 0, cont = 0; i < nbits; i++)
if (rs[i]) {
if (cont) printf("∨");
cont = 1;
putchar('(');
for (int j = 0; j < n; j++) {
if (j) printf("∧");
if (! qs[i][j]) printf("¬");
printf("P_%d", j + 1);
}
putchar(')');
}
putchar('\n');
}
return 0;
}
tnakao0123