結果

問題 No.2090 否定論理積と充足可能性
ユーザー 👑 kakel-sankakel-san
提出日時 2022-09-30 22:16:37
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 1,201 bytes
コンパイル時間 1,766 ms
コンパイル使用メモリ 65,860 KB
実行使用メモリ 24,364 KB
最終ジャッジ日時 2023-08-24 15:50:15
合計ジャッジ時間 3,653 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
22,340 KB
testcase_01 AC 58 ms
22,276 KB
testcase_02 AC 58 ms
24,364 KB
testcase_03 AC 58 ms
22,212 KB
testcase_04 AC 57 ms
22,360 KB
testcase_05 AC 59 ms
22,352 KB
testcase_06 AC 59 ms
24,356 KB
testcase_07 AC 58 ms
22,340 KB
testcase_08 AC 58 ms
22,404 KB
testcase_09 AC 58 ms
20,240 KB
testcase_10 AC 58 ms
22,332 KB
testcase_11 AC 57 ms
22,208 KB
testcase_12 AC 58 ms
24,360 KB
testcase_13 AC 58 ms
24,268 KB
testcase_14 AC 58 ms
24,360 KB
testcase_15 AC 58 ms
22,192 KB
testcase_16 AC 58 ms
24,236 KB
testcase_17 AC 58 ms
22,292 KB
testcase_18 AC 58 ms
24,244 KB
testcase_19 AC 58 ms
20,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
    }
}
0