結果
| 問題 | No.3500 01 String |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-17 21:47:33 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 635 bytes |
| 記録 | |
| コンパイル時間 | 6,395 ms |
| コンパイル使用メモリ | 374,224 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-17 21:47:43 |
| 合計ジャッジ時間 | 8,013 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using mint = modint998244353;
int main() {
cin.tie(nullptr) -> sync_with_stdio(false);
int n;
string a;
cin >> n >> a;
vector<int> b;
for (int i = 0; i < n;) {
int j = i;
while (j < n and a[j] == a[i]) ++j;
b.push_back(j-i);
i = j;
}
mint ans = 1;
int st = (a[0] == '0' ? 0 : 1);
for (int i = st; i+1 < b.size(); i += 2) {
ans *= b[i]+b[i+1]+1;
}
cout << ans.val() << '\n';
return 0;
}