結果
| 問題 | No.3500 01 String |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 03:26:17 |
| 言語 | JavaScript (node v25.8.2) |
| 結果 |
AC
|
| 実行時間 | 154 ms / 2,000 ms |
| コード長 | 562 bytes |
| 記録 | |
| コンパイル時間 | 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 |
ソースコード
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)+"")