結果

問題 No.2541 Divide 01 String
ユーザー yansi819yansi819
提出日時 2024-04-05 10:33:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 4,347 ms
コンパイル使用メモリ 264,976 KB
実行使用メモリ 14,520 KB
最終ジャッジ日時 2024-04-05 10:33:21
合計ジャッジ時間 6,328 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 5 ms
6,548 KB
testcase_04 AC 14 ms
8,960 KB
testcase_05 AC 21 ms
13,660 KB
testcase_06 AC 12 ms
8,064 KB
testcase_07 AC 22 ms
13,572 KB
testcase_08 AC 23 ms
14,520 KB
testcase_09 AC 23 ms
14,520 KB
testcase_10 AC 23 ms
14,520 KB
testcase_11 AC 22 ms
14,520 KB
testcase_12 AC 23 ms
14,520 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 2 ms
6,548 KB
testcase_15 AC 1 ms
6,548 KB
testcase_16 AC 1 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 16 ms
10,496 KB
testcase_19 AC 16 ms
10,496 KB
testcase_20 AC 15 ms
10,368 KB
testcase_21 AC 13 ms
8,704 KB
testcase_22 AC 13 ms
8,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

int N;
string S;
const ll mod = 998244353;

int main() {
  cin >> N >> S;
  vector dp(N + 1, vector(2, 0LL));
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    if (S[i] == '0') dp[i + 1][0] += dp[i][0] + dp[i][1];
    else dp[i + 1][1] += dp[i][0] + dp[i][1];
    dp[i + 1][1] += dp[i][1];
    dp[i + 1][0] %= mod;
    dp[i + 1][1] %= mod;
  }
  cout << dp[N][1] << endl;
  return 0;
}
0