結果
問題 | No.2090 否定論理積と充足可能性 |
ユーザー | harurun |
提出日時 | 2022-09-30 22:20:37 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,992 bytes |
コンパイル時間 | 3,692 ms |
コンパイル使用メモリ | 191,308 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 00:04:22 |
合計ジャッジ時間 | 4,538 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <deque> #include <queue> #include <string> #include <iomanip> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <utility> #include <stack> #include <random> #include <complex> #include <functional> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <assert.h> #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif using namespace std; using ll=long long; #define read(x) cin>>(x); #define readll(x) ll (x);cin>>(x); #define readS(x) string (x);cin>>(x); #define readvll(x,N) vector<ll> (x)((N));for(int i=0;i<(N);i++){cin>>(x)[i];} #define rep(i,N) for(ll (i)=0;(i)<(N);(i)++) #define rep2d(i,j,H,W) for(ll (i)=0;(i)<(H);(i)++)for(ll (j)=0;(j)<(W);j++) #define is_in(x,y) (0<=(x) && (x)<H && 0<=(y) && (y)<W) #define yn {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} #define double_out(x) fixed << setprecision(x) template<class T> inline void erase_duplicate(vector<T>& A){sort(A.begin(),A.end());A.erase(unique(A.begin(),A.end()),A.end());} inline ll powll(ll x,ll n){ll r=1;while(n>0){if(n&1){r*=x;};x*=x;n>>=1;};return r;} inline bool NAND(bool P,bool Q){ if(P && Q){ return false; }else{ return true; } } inline bool f(const vector<bool> C){ return NAND(NAND(NAND(C[0],C[1]),C[2]),NAND(NAND(C[3],C[4]),C[5])); } int main(){ const ll N=6; vector<string> A(N); for(ll i=0;i<N;i++){ cin>>A[i]; } ll M=1<<N; for(ll i=0;i<M;i++){ vector<bool> B(N,false); for(ll j=0;j<N;j++){ if((i>>j)&1){ B[j]=true; } } if(f(B)){ ll flag=0; for(ll j=0;j<N;j++){ for(ll k=0;k<N;k++){ if(A[j]==A[k] && B[j]!=B[k]){ flag=1; break; } } if(flag==1){ break; } } if(flag==0){ cout<<"YES"<<endl; return 0; } } } cout<<"NO"<<endl; }