結果
| 問題 | No.3500 01 String |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 14:13:50 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 796 bytes |
| 記録 | |
| コンパイル時間 | 820 ms |
| コンパイル使用メモリ | 195,924 KB |
| 実行使用メモリ | 10,948 KB |
| 最終ジャッジ日時 | 2026-04-18 14:13:58 |
| 合計ジャッジ時間 | 4,614 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
use std::io::{self, Read};
const MOD: u64 = 998244353;
fn main() {
let mut s = String::new();
io::stdin().read_to_string(&mut s).unwrap();
let mut it = s.split_whitespace();
let n: usize = it.next().unwrap().parse().unwrap();
let a = it.next().unwrap().as_bytes().to_vec();
let mut runs = Vec::<(u8, usize)>::new();
let mut i = 0usize;
while i < n {
let mut j = i;
while j < n && a[j] == a[i] {
j += 1;
}
runs.push((a[i], j - i));
i = j;
}
let mut ans = 1u64;
for i in 0..runs.len().saturating_sub(1) {
if runs[i].0 == b'0' && runs[i + 1].0 == b'1' {
let x = (runs[i].1 + runs[i + 1].1 + 1) as u64;
ans = ans * x % MOD;
}
}
println!("{}", ans);
}