結果
問題 | No.2279 OR Insertion |
ユーザー |
![]() |
提出日時 | 2023-04-19 14:02:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 705 bytes |
コンパイル時間 | 2,158 ms |
コンパイル使用メモリ | 198,680 KB |
最終ジャッジ日時 | 2025-02-12 10:15:48 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 TLE * 33 |
ソースコード
#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; }