結果
| 問題 |
No.2541 Divide 01 String
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-24 22:04:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 614 bytes |
| コンパイル時間 | 701 ms |
| コンパイル使用メモリ | 76,464 KB |
| 最終ジャッジ日時 | 2025-02-18 00:08:41 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
int main(void)
{
int N;
std::string S;
std::cin >> N >> S;
std::vector<int> zeros;
int count = 0;
for (auto& c : S)
{
if (c == '0') { count++; }
if (c == '1')
{
if (zeros.empty())
{
zeros.push_back(1);
}
else
{
zeros.push_back(count + 2);
}
count = 0;
}
}
if (zeros.empty())
{
std::cout << '0' << std::endl;
return 0;
}
long long ans = 1;
for (auto& e : zeros)
{
ans *= e;
ans %= 998244353;
}
std::cout << ans << std::endl;
return 0;
}