結果
| 問題 | No.3500 01 String |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-17 23:43:49 |
| 言語 | C++23(gnu拡張) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 932 bytes |
| 記録 | |
| コンパイル時間 | 6,944 ms |
| コンパイル使用メモリ | 378,424 KB |
| 実行使用メモリ | 8,292 KB |
| 最終ジャッジ日時 | 2026-04-17 23:44:04 |
| 合計ジャッジ時間 | 8,131 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)
template <class T> bool chmin(T& x, T y) {
return x > y ? (x = y, true) : false;
}
template <class T> bool chmax(T& x, T y) {
return x < y ? (x = y, true) : false;
}
using mint = atcoder::modint998244353;
void solve() {
int n;
cin >> n;
string s;
cin >> s;
s.insert(s.begin(), '1');
s.push_back('0');
vector<pair<int, int>> vp = {{s[0], 0}};
for (char c : s) {
if (vp.back().first == c) vp.back().second++;
else vp.push_back({c, 1});
}
int m = vp.size();
mint ans = 1;
for (int i = 1; i < m - 1; i += 2) {
ans *= vp[i].second + vp[i + 1].second + 1;
}
cout << ans.val() << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
int t = 1;
// cin >> t;
while (t--) solve();
}