結果

問題 No.2279 OR Insertion
コンテスト
ユーザー miscalc
提出日時 2023-04-19 14:02:07
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 705 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,513 ms
コンパイル使用メモリ 214,992 KB
実行使用メモリ 10,352 KB
最終ジャッジ日時 2026-06-30 09:13:54
合計ジャッジ時間 9,316 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 TLE * 2 -- * 45
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main()
{
  int N;
  string S;
  cin >> N >> S;

  mint ans = 0;
  for (ll k = 0; k < N; k++)
  {
    vector<mint> dp(N + 1, 0);
    dp.at(0) = 1;

    for (ll i = 0; i < N; i++)
    {
      if (i - k < 0 || S.at(i - k) == '0')
      {
        for (ll j = 0; j <= i; j++)
        {
          dp[i + 1] += dp[j];
        }
      }
      else
      {
        for (ll j = i - k + 1; j <= i; j++)
        {
          dp[i + 1] += dp[j];
        }
      }
    }
    ans += (mint(2).pow(N - 1) - dp.at(N)) * mint(2).pow(k);
  }
  cout << ans.val() << endl;
}
0