結果

問題 No.1709 Indistinguishable by MEX
ユーザー 👑 kakel-sankakel-san
提出日時 2023-12-26 23:44:29
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 8,567 ms
コンパイル使用メモリ 157,752 KB
実行使用メモリ 188,076 KB
最終ジャッジ日時 2023-12-26 23:44:46
合計ジャッジ時間 13,530 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
32,548 KB
testcase_01 AC 76 ms
32,548 KB
testcase_02 AC 75 ms
32,548 KB
testcase_03 AC 76 ms
32,548 KB
testcase_04 AC 74 ms
32,548 KB
testcase_05 AC 75 ms
32,548 KB
testcase_06 AC 76 ms
32,548 KB
testcase_07 AC 76 ms
32,548 KB
testcase_08 AC 135 ms
45,220 KB
testcase_09 AC 101 ms
43,044 KB
testcase_10 AC 108 ms
47,980 KB
testcase_11 AC 96 ms
41,380 KB
testcase_12 AC 96 ms
41,124 KB
testcase_13 AC 102 ms
44,196 KB
testcase_14 AC 101 ms
43,428 KB
testcase_15 AC 103 ms
43,940 KB
testcase_16 AC 109 ms
47,284 KB
testcase_17 AC 107 ms
46,180 KB
testcase_18 AC 113 ms
47,788 KB
testcase_19 AC 115 ms
47,788 KB
testcase_20 AC 112 ms
47,788 KB
testcase_21 AC 110 ms
47,788 KB
testcase_22 AC 110 ms
47,788 KB
testcase_23 AC 111 ms
47,788 KB
testcase_24 AC 111 ms
47,788 KB
testcase_25 AC 111 ms
47,788 KB
testcase_26 AC 76 ms
32,548 KB
testcase_27 AC 97 ms
41,892 KB
testcase_28 AC 96 ms
188,076 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (100 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.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 p = NList;
        WriteLine(Mex(n, p));
    }
    static long Mex(int n, int[] p)
    {
        var pos = new int[n];
        for (var i = 0; i < n; ++i) pos[p[i]] = i;
        var left = n + 1;
        var right = -1;
        var ans = 1L;
        var mod = 998_244_353;
        for (var i = 0; i < n; ++i)
        {
            var cnt = 1;
            if (left <= pos[i] && pos[i] <= right)
            {
                cnt = right - left - i + 1;
            }
            if (pos[i] < left)
            {
                left = pos[i];
            }
            if (right < pos[i])
            {
                right = pos[i];
            }
            ans = ans * cnt % mod;
        }
        return ans;
    }
}
0