結果

問題 No.2279 OR Insertion
ユーザー magstamagsta
提出日時 2023-04-19 14:18:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 883 bytes
コンパイル時間 2,371 ms
コンパイル使用メモリ 170,208 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-04-22 15:21:02
合計ジャッジ時間 28,440 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 108 ms
5,376 KB
testcase_03 AC 35 ms
5,376 KB
testcase_04 TLE -
testcase_05 AC 7 ms
5,376 KB
testcase_06 AC 557 ms
5,376 KB
testcase_07 AC 639 ms
5,376 KB
testcase_08 AC 118 ms
5,376 KB
testcase_09 AC 972 ms
5,376 KB
testcase_10 TLE -
testcase_11 AC 83 ms
5,376 KB
testcase_12 AC 1,444 ms
5,376 KB
testcase_13 AC 22 ms
5,376 KB
testcase_14 AC 32 ms
5,376 KB
testcase_15 AC 728 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 534 ms
5,376 KB
testcase_18 AC 1,168 ms
5,376 KB
testcase_19 AC 1,730 ms
5,376 KB
testcase_20 AC 634 ms
5,376 KB
testcase_21 AC 400 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 TLE -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 AC 1,919 ms
5,376 KB
testcase_49 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

  mint ans = 0;
  ll dp[4010];
  for (ll k = 0; k < N; k++)
  {
    dp[0] = 1;
    for (int i = 1; i <= N; i++)
    {
      dp[i] = 0;
    }

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