結果
| 問題 | 
                            No.792 真理関数をつくろう
                             | 
                    
| コンテスト | |
| ユーザー | 
                             rtia_iidx
                         | 
                    
| 提出日時 | 2019-02-22 21:37:13 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,742 bytes | 
| コンパイル時間 | 1,848 ms | 
| コンパイル使用メモリ | 107,832 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-11-25 07:50:07 | 
| 合計ジャッジ時間 | 2,267 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 2 | 
| other | WA * 22 | 
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
using namespace std;
#define ll long long int
ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    ll t = 1 << n;
    vector<vector<bool>> q(n,vector<bool>(t));
    vector<bool> r(t);
    for(int i = 0; i < t; i++){
        int tmp;
        for(int j = 0; j < n; j++){
            cin >> tmp;
            q[j][i] = (bool)tmp;
        }
        cin >> tmp;
        r[i] = (bool)tmp;
    }
    bool allt = true;
    bool allf = true;
    int c = 0;
    for(int i = 0; i < t; i++){
        if(r[i])c++;
        allt = allt && r[i];
        allf = allf && (!r[i]);
    }
    if(allt){
        cout << "A=⊤";
        return 0;
    }
    if(allf){
        cout << "A=⊥";
        return 0;
    }
    string ans = "A=";
    
    bool flag = false;
    for(int i = 0; i < t; i++){
        if(r[i]){
            if(flag){
                ans += "∨";
            }
            if(c > 1){
                ans += "(";
            }
            for(int j = 0; j < n; j++){
                if(j > 1){
                    ans += "∧";
                }
                if(!q[j][i]){
                    ans += "¬";
                }
                ans += "P_";
                ans += to_string(i+1);
            }
            if(c > 1){
                ans += ")";
            }
            flag = true;
        }
    }
    cout << ans << endl;
    
    return 0;
}
            
            
            
        
            
rtia_iidx