結果

問題 No.1677 mæx
ユーザー 👑 kakel-sankakel-san
提出日時 2024-01-04 01:03:54
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,659 bytes
コンパイル時間 14,103 ms
コンパイル使用メモリ 158,664 KB
実行使用メモリ 189,952 KB
最終ジャッジ日時 2024-01-04 01:04:13
合計ジャッジ時間 10,204 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
31,012 KB
testcase_01 AC 54 ms
31,012 KB
testcase_02 AC 56 ms
31,012 KB
testcase_03 AC 54 ms
31,012 KB
testcase_04 AC 77 ms
38,564 KB
testcase_05 AC 78 ms
38,436 KB
testcase_06 AC 77 ms
38,436 KB
testcase_07 AC 77 ms
38,436 KB
testcase_08 AC 77 ms
38,564 KB
testcase_09 AC 77 ms
38,564 KB
testcase_10 AC 77 ms
38,564 KB
testcase_11 AC 77 ms
38,564 KB
testcase_12 AC 77 ms
38,436 KB
testcase_13 AC 76 ms
38,436 KB
testcase_14 AC 89 ms
40,868 KB
testcase_15 AC 88 ms
40,868 KB
testcase_16 AC 89 ms
40,868 KB
testcase_17 AC 88 ms
40,868 KB
testcase_18 AC 87 ms
40,868 KB
testcase_19 AC 55 ms
31,012 KB
testcase_20 AC 55 ms
31,012 KB
testcase_21 AC 89 ms
189,952 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (96 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 s = ReadLine();
        var k = NN;
        var pos = 0;
        WriteLine(DFS(s, ref pos)[k]);
    }
    static int mod = 998_244_353;
    static int[][] mex = new int[][] {
        new int[] { 1, 2, 1 },
        new int[] { 2, 0, 0 },
        new int[] { 1, 0, 0 },
    };
    static int[][] max = new int[][] {
        new int[] { 0, 1, 2 },
        new int[] { 1, 1, 2 },
        new int[] { 2, 2, 2 },
    };
    static long[] DFS(string s, ref int pos)
    {
        var ans = new long[3];
        if (s[pos] != 'm')
        {
            if (s[pos] == '?') ans = new long[] { 1, 1, 1 };
            else ans[s[pos] - '0'] = 1;
            pos += 2;
            return ans;
        }
        var domex = s[pos + 1] != 'a';
        var domax = s[pos + 1] != 'e';
        long[] a;
        long[] b;
        pos += 4;
        a = DFS(s, ref pos);
        b = DFS(s, ref pos);
        ++pos;
        for (var i = 0; i < 3; ++i) for (var j = 0; j < 3; ++j)
        {
            if (domex) ans[mex[i][j]] = (ans[mex[i][j]] + a[i] * b[j] % mod) % mod;
            if (domax) ans[max[i][j]] = (ans[max[i][j]] + a[i] * b[j] % mod) % mod;
        }
        return ans;
    }
}
0