結果
| 問題 | No.2541 Divide 01 String | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-11-24 21:29:56 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 622 bytes | 
| コンパイル時間 | 4,088 ms | 
| コンパイル使用メモリ | 253,460 KB | 
| 最終ジャッジ日時 | 2025-02-17 23:46:05 | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 11 WA * 9 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::modint998244353;
using namespace std;
vector<pair<int, int>> RLE(string A){
	int N = A.size();
	vector<pair<int, int>> ret;
	for (int l = 0; l < N;){
		int r = l + 1;
		while (r < N and A[l] == A[r]){
			r++;
		};
		ret.push_back({A[l], r - l});
		l = r;
	}
	return ret;
}
int main(){
	int N;
	cin >> N;
	string S;
	cin >> S;
	auto P = RLE(S);
	mint ans = 1;
	int M = P.size();
	for (int i = 1; i < M - 1; i++){
		if (P[i].first == '0'){
			ans *= P[i].second + 2;
		} else {
			ans *= mint(2).pow(P[i].second - 1);
		}
	}
	cout << ans.val() << endl;
}
            
            
            
        