結果

問題 No.3500 01 String
コンテスト
ユーザー Atake-MKU
提出日時 2026-04-18 03:26:17
言語 JavaScript
(node v25.8.2)
コンパイル:
true
実行:
node _filename_ ONLINE_JUDGE
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 562 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 191 ms
コンパイル使用メモリ 6,528 KB
実行使用メモリ 72,840 KB
最終ジャッジ日時 2026-04-18 03:26:31
合計ジャッジ時間 4,270 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

function Main(input) {
    input = input.split("\n");
    const N = Number(input[0]);
    const A = input[1].trim().split("").map(Number);

    while (A.length && A.at(-1) == 0) A.pop();
    let i = 0;
    while (i < A.length && A[i] === 1) i++;
    A.push(0);

    let ans = 1;
    let mod = 998244353;
    let cnt = 1;

    while (i < A.length - 1) {
        cnt++;
        if (A[i] - A[i + 1] > 0) {
            ans *= cnt;
            ans %= mod;
            cnt = 1;
        }
        i++;
    }
    console.log(ans)
}
Main(require("fs").readFileSync(0)+"")
0