結果

問題 No.2541 Divide 01 String
ユーザー achapiachapi
提出日時 2023-11-24 21:32:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 4,865 ms
コンパイル使用メモリ 264,920 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-24 21:33:03
合計ジャッジ時間 6,268 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 3 ms
6,676 KB
testcase_04 AC 6 ms
6,676 KB
testcase_05 AC 9 ms
6,676 KB
testcase_06 AC 5 ms
6,676 KB
testcase_07 AC 9 ms
6,676 KB
testcase_08 AC 9 ms
6,676 KB
testcase_09 AC 9 ms
6,676 KB
testcase_10 AC 6 ms
6,676 KB
testcase_11 AC 7 ms
6,676 KB
testcase_12 AC 7 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 = 0; i < M; i++){
		if (P[i].first == '0'){
			if (i != 0 and i != M - 1){
				ans *= P[i].second + 2;
			}
		} else {
			ans *= mint(2).pow(P[i].second - 1);
		}
	}
	cout << ans.val() << endl;
}
0