結果
| 問題 |
No.2541 Divide 01 String
|
| コンテスト | |
| ユーザー |
inkyaman
|
| 提出日時 | 2024-03-24 15:29:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 766 bytes |
| コンパイル時間 | 1,248 ms |
| コンパイル使用メモリ | 115,800 KB |
| 最終ジャッジ日時 | 2025-02-20 13:38:44 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;
int N;
string S;
ll mod = 998244353;
int main() {
cin >> N >> S;
vector<ll> pos1;
for(int i = 0; i < N; ++i) {
if(S[i] == '1') pos1.push_back(i);
}
if(pos1.size() == 0) {
cout << 0 << endl;
return 0;
}
ll ans = 1;
for(int i = 0; i < pos1.size()-1; ++i) {
ans *= pos1[i+1]-pos1[i]+1;
ans %= mod;
}
cout << ans << endl;
}
inkyaman