結果

問題 No.2178 Payable Magic Items
ユーザー 👑 kakel-sankakel-san
提出日時 2023-09-05 19:43:17
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 178 ms / 4,000 ms
コード長 1,537 bytes
コンパイル時間 1,339 ms
コンパイル使用メモリ 61,528 KB
実行使用メモリ 30,128 KB
最終ジャッジ日時 2023-09-05 19:43:24
合計ジャッジ時間 6,525 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
16,056 KB
testcase_01 AC 63 ms
15,976 KB
testcase_02 AC 64 ms
15,888 KB
testcase_03 AC 112 ms
20,556 KB
testcase_04 AC 63 ms
15,852 KB
testcase_05 AC 110 ms
20,560 KB
testcase_06 AC 110 ms
20,484 KB
testcase_07 AC 64 ms
15,924 KB
testcase_08 AC 111 ms
20,500 KB
testcase_09 AC 79 ms
20,152 KB
testcase_10 AC 63 ms
16,140 KB
testcase_11 AC 178 ms
30,000 KB
testcase_12 AC 177 ms
29,940 KB
testcase_13 AC 177 ms
30,120 KB
testcase_14 AC 176 ms
30,116 KB
testcase_15 AC 176 ms
30,016 KB
testcase_16 AC 176 ms
30,128 KB
testcase_17 AC 139 ms
23,628 KB
testcase_18 AC 64 ms
16,380 KB
testcase_19 AC 87 ms
22,040 KB
testcase_20 AC 63 ms
16,176 KB
testcase_21 AC 65 ms
16,336 KB
testcase_22 AC 66 ms
16,412 KB
testcase_23 AC 66 ms
16,224 KB
testcase_24 AC 161 ms
27,032 KB
testcase_25 AC 120 ms
21,904 KB
testcase_26 AC 92 ms
23,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, k) = (c[0], c[1]);
        var s = SList(n);
        var bitmax = (int)Math.Pow(5, k);
        var exist = new bool[bitmax];
        var upper = Enumerable.Repeat(true, bitmax).ToArray();
        var pow = new int[k];
        for (var i = 0; i < k; ++i) pow[i] = (int)Math.Pow(5, i);
        foreach (var si in s)
        {
            var id = 0;
            for (var i = 0; i < k; ++i) id += (si[i] - '0') * pow[i];
            exist[id] = true;
        }
        for (var b = bitmax - 1; b >= 0; --b)
        {
            var list = new int[k];
            var tmp = b;
            for (var i = 0; i < k; ++i)
            {
                list[i] = tmp % 5;
                tmp /= 5;
            }
            for (var i = 0; i < k; ++i) if (list[i] > 0)
            {
                var prev = b - pow[i];
                if (!upper[b] || exist[b]) upper[prev] = false;
            }
        }
        var ans = 0;
        for (var b = 0; b < bitmax; ++b) if (exist[b] && !upper[b]) ++ans;
        WriteLine(ans);
    }
}
0