結果

問題 No.1885 Flat Permutation
ユーザー kakel-sankakel-san
提出日時 2023-11-22 21:42:19
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,009 bytes
コンパイル時間 13,279 ms
コンパイル使用メモリ 166,040 KB
実行使用メモリ 185,264 KB
最終ジャッジ日時 2024-09-26 07:40:52
合計ジャッジ時間 17,417 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (87 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 long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, x, y) = (c[0], c[1], c[2]);
        if (x > y) (x, y) = (y, x);
        if (x > 1) ++x;
        if (y < n) --y;
        if (x > 0)
        {
            y -= x;
            x = 0;
        }
        if (y < 0)
        {
            WriteLine(0);
            return;
        }
        var mod = 998_244_353;
        var dp = new long[y + 1];
        dp[0] = 1;
        for (var i = 0; i < dp.Length; ++i)
        {
            if (i + 3 < dp.Length) dp[i + 3] = (dp[i + 3] + dp[i]) % mod;
            if (i + 1 < dp.Length) dp[i + 1] = (dp[i + 1] + dp[i]) % mod;
        }
        WriteLine(dp.Last());
    }
}
0