結果
問題 | No.2541 Divide 01 String |
ユーザー |
![]() |
提出日時 | 2024-10-21 10:08:16 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 709 bytes |
コンパイル時間 | 2,399 ms |
コンパイル使用メモリ | 204,412 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-21 10:08:20 |
合計ジャッジ時間 | 3,865 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/modint>using namespace std;using ll = long long;using namespace atcoder;using mint = modint998244353;int main(){cin.tie(nullptr);ios_base::sync_with_stdio(false);int N, x=1;mint ans=1;string S;cin >> N >> S;while (!S.empty() && S.back() == '0') S.pop_back();reverse(S.begin(), S.end());while (!S.empty() && S.back() == '0') S.pop_back();reverse(S.begin(), S.end());if (S.empty()){cout << 0 << endl;return 0;}for (auto c : S){if (c == '1'){ans *= x;x = 2;}else x++;}cout << ans.val() << endl;return 0;}