結果

問題 No.2783 4-33 Easy
ユーザー 👑 kakel-sankakel-san
提出日時 2024-06-23 21:40:05
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 305 ms / 2,000 ms
コード長 2,224 bytes
コンパイル時間 13,523 ms
コンパイル使用メモリ 168,640 KB
実行使用メモリ 211,648 KB
最終ジャッジ日時 2024-06-23 21:40:28
合計ジャッジ時間 21,486 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
32,256 KB
testcase_01 AC 80 ms
34,560 KB
testcase_02 AC 76 ms
33,664 KB
testcase_03 AC 75 ms
33,408 KB
testcase_04 AC 222 ms
55,936 KB
testcase_05 AC 286 ms
55,936 KB
testcase_06 AC 290 ms
55,936 KB
testcase_07 AC 289 ms
55,936 KB
testcase_08 AC 288 ms
56,064 KB
testcase_09 AC 280 ms
55,936 KB
testcase_10 AC 280 ms
56,192 KB
testcase_11 AC 275 ms
56,064 KB
testcase_12 AC 276 ms
55,936 KB
testcase_13 AC 277 ms
56,188 KB
testcase_14 AC 280 ms
56,192 KB
testcase_15 AC 276 ms
56,320 KB
testcase_16 AC 277 ms
56,064 KB
testcase_17 AC 275 ms
56,064 KB
testcase_18 AC 280 ms
56,044 KB
testcase_19 AC 279 ms
56,180 KB
testcase_20 AC 280 ms
55,936 KB
testcase_21 AC 279 ms
55,936 KB
testcase_22 AC 278 ms
56,064 KB
testcase_23 AC 305 ms
55,936 KB
testcase_24 AC 278 ms
56,064 KB
testcase_25 AC 274 ms
56,064 KB
testcase_26 AC 279 ms
56,064 KB
testcase_27 AC 281 ms
56,184 KB
testcase_28 AC 276 ms
211,648 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (91 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

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 int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var a = NList;
        var b = ReadLine().Split();
        var ninex = new int[5];
        var cards = new List<(int a, int b)>();
        for (var i = 0; i < n; ++i)
        {
            if (b[i].Contains('X'))
            {
                if (b[i] == "X")
                {
                    ++ninex[a[i]];
                }
            }
            else cards.Add((a[i], int.Parse(b[i])));
        }
        var mod = 998_244_353;
        var dp = new long[10][];
        for (var i = 0; i < dp.Length; ++i) dp[i] = new long[434];
        dp[0][0] = 1;
        for (var i = 0; i < cards.Count; ++i)
        {
            var ndp = new long[10][];
            for (var j = 0; j < ndp.Length; ++j) ndp[j] = new long[434];
            for (var j = 0; j < dp.Length; ++j) for (var k = 0; k < dp[j].Length; ++k)
            {
                ndp[j][k] = (ndp[j][k] + dp[j][k]) % mod;
                var p = k / 100;
                var q = k % 100;
                if (j + 1 < ndp.Length && p + cards[i].a <= 4 && q + cards[i].b <= 33)
                    ndp[j + 1][k + cards[i].a * 100 + cards[i].b] =
                        (ndp[j + 1][k + cards[i].a * 100 + cards[i].b] + dp[j][k]) % mod;
            }
            dp = ndp;
        }
        WriteLine(
            (dp[8][33] * ninex[4] + dp[8][133] * ninex[3] + dp[8][233] * ninex[2] + dp[8][333] * ninex[1]
            + dp[8][433] * ninex[0]) % mod
        );
    }
    static int GetPt(string x)
    {
        x = x.Replace("X", "");
        if (x == "") return 0;
        return int.Parse(x);
    }
    static long GCD(long a, long b)
    {
        if (a < b) return GCD(b, a);
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }
}
0