結果
問題 |
No.2541 Divide 01 String
|
ユーザー |
|
提出日時 | 2023-11-24 21:31:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 644 bytes |
コンパイル時間 | 3,503 ms |
コンパイル使用メモリ | 252,220 KB |
最終ジャッジ日時 | 2025-02-17 23:47:34 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 13 |
ソースコード
#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' and i != 0 and i != M - 1){ ans *= P[i].second + 2; } else { ans *= mint(2).pow(P[i].second - 1); } } cout << ans.val() << endl; }