結果
| 問題 |
No.2541 Divide 01 String
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2024-10-21 10:08:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 709 bytes |
| コンパイル時間 | 3,548 ms |
| コンパイル使用メモリ | 196,456 KB |
| 最終ジャッジ日時 | 2025-02-24 22:09:27 |
|
ジャッジサーバーID (参考情報) |
judge5 / 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;
}
srjywrdnprkt