結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー kakel-san
提出日時 2025-10-17 21:47:24
言語 C#
(.NET 8.0.404)
結果
MLE  
実行時間 -
コード長 1,497 bytes
コンパイル時間 8,241 ms
コンパイル使用メモリ 167,832 KB
実行使用メモリ 189,768 KB
最終ジャッジ日時 2025-10-17 21:47:46
合計ジャッジ時間 21,428 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 MLE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (102 ミリ秒)。
  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;
using System.Globalization;

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();
    static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray();
    static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    static long[] LList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => long.Parse(ReadLine())).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, q) = (c[0], c[1]);
        var a = NList;
        var b = NList;
        var mod = 998_244_353;
        var dp = new long[n + 1];
        var ndp = new long[n + 1];
        dp[0] = 1;
        for (var i = 0; i < n; ++i)
        {
            for (var j = 0; j <= n; ++j) ndp[j] = 0;
            for (var j = 0; j < n; ++j)
            {
                ndp[j] = (ndp[j] + dp[j] * (a[i] - 1) % mod) % mod;
                ndp[j + 1] = (ndp[j + 1] + dp[j] % mod) % mod;
            }
            (dp, ndp) = (ndp, dp);
        }
        for (var i = 0; i < q; ++i) WriteLine(dp[b[i]]);
    }
}
0