結果
問題 | No.2541 Divide 01 String |
ユーザー |
![]() |
提出日時 | 2024-01-05 00:27:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 710 bytes |
コンパイル時間 | 2,339 ms |
コンパイル使用メモリ | 197,960 KB |
最終ジャッジ日時 | 2025-02-18 16:14:27 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef LOCAL#include "settings/debug.cpp"#define _GLIBCXX_DEBUG#else#define Debug(...) void(0)#endif#define rep(i, n) for (int i = 0; i < (n); ++i)using ll = long long;using ull = unsigned long long;#include <atcoder/modint>using mint = atcoder::modint998244353;void operator<<(ostream& os, const mint& m) {os << m.val();}int main() {int n;string s;cin >> n >> s;vector dp(n + 1, vector<mint>(2, 0));dp[0][0] = 1;rep(i, n) {// 分割しないdp[i + 1][1] = dp[i][1];// 分割するdp[i + 1][s[i] == '1'] += dp[i][0] + dp[i][1];Debug(dp[i + 1]);}cout << dp[n][1].val() << endl;return 0;}