結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 WA -
testcase_04 AC 6 ms
6,676 KB
testcase_05 WA -
testcase_06 AC 5 ms
6,676 KB
testcase_07 AC 8 ms
6,676 KB
testcase_08 WA -
testcase_09 AC 9 ms
6,676 KB
testcase_10 AC 6 ms
6,676 KB
testcase_11 AC 6 ms
6,676 KB
testcase_12 AC 6 ms
6,676 KB
testcase_13 WA -
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 1 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 = 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;
}
0