結果

問題 No.3458 Scores of Subsequence
コンテスト
ユーザー InTheBloom
提出日時 2026-02-28 14:27:35
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 599 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,028 ms
コンパイル使用メモリ 174,184 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-02-28 14:27:57
合計ジャッジ時間 4,946 ms
ジャッジサーバーID
(参考情報)
judge4 / judge7
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import std;

void main () {
    const long MOD = 998244353;
    string S = readln.chomp;

    // いや、数学かと思ったらギャグで横転

    long ans = 0;
    long count = 1;
    foreach (c; S) {
        if (c == 'M') {
            count *= 3;
            count %= MOD;
        }
        if (c == 'A') {
            ans += count;
        }
    }

    ans %= MOD;
    writeln(ans);
}

void read (T...) (string S, ref T args) {
    import std.conv : to;
    import std.array : split;
    auto buf = S.split;
    foreach (i, ref arg; args) {
        arg = buf[i].to!(typeof(arg));
    }
}
0