結果
問題 | No.2090 否定論理積と充足可能性 |
ユーザー |
|
提出日時 | 2022-09-30 22:16:37 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 1,201 bytes |
コンパイル時間 | 799 ms |
コンパイル使用メモリ | 110,692 KB |
実行使用メモリ | 28,036 KB |
最終ジャッジ日時 | 2024-12-23 00:01:07 |
合計ジャッジ時間 | 2,245 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;using static System.Console;using System.Linq;using System.Collections.Generic;class Program{static void Main(){Solve();}static void Solve(){var n = ReadLine().Split(' ');var set = new HashSet<string>(n);var list = new List<string>(set);var dic = new Dictionary<string, int>();for (var i = 0; i < list.Count; ++i) dic[list[i]] = i;var cmp = new int[n.Length];for (var i = 0; i < n.Length; ++i) cmp[i] = dic[n[i]];var bitmax = 1 << list.Count;for (var b = 0; b < bitmax; ++b){var map = new bool[list.Count];var tmp = b;for (var i = 0; i < map.Length; ++i){map[i] = tmp % 2 == 1;tmp >>= 1;}if (Nand(Nand(Nand(map[cmp[0]], map[cmp[1]]), map[cmp[2]]), Nand(Nand(map[cmp[3]], map[cmp[4]]), map[cmp[5]]))){WriteLine("YES");return;}}WriteLine("NO");}static bool Nand(bool a, bool b){return !(a & b);}}