結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-17 23:47:56 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 670 bytes |
| 記録 | |
| コンパイル時間 | 3,648 ms |
| コンパイル使用メモリ | 333,740 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-17 23:48:11 |
| 合計ジャッジ時間 | 9,110 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | RE * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 998244353LL;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
string S;
cin >> N >> S;
vector<pair<char, int>> runs;
for (int i = 0; i < N; ) {
int j = i;
while (j < N && S[j] == S[i]) j++;
runs.push_back({S[i], j - i});
i = j;
}
long long ans = 1;
for (int i = 0; i + 1 < (int)runs.size(); i++) {
if (runs[i].first == '0' && runs[i + 1].first == '1') {
ans = ans * (runs[i].second + runs[i + 1].second + 1LL) % MOD;
}
}
cout << ans % MOD << '\n';
return 0;
}