結果
| 問題 |
No.2279 OR Insertion
|
| コンテスト | |
| ユーザー |
ぷら
|
| 提出日時 | 2023-04-21 22:22:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| コード長 | 838 bytes |
| コンパイル時間 | 1,696 ms |
| コンパイル使用メモリ | 193,680 KB |
| 最終ジャッジ日時 | 2025-02-12 11:57:08 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 48 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 998244353;
int dp[4040];
void mpl(int &x,int y) {
x += y;
if(x >= mod) x -= mod;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
string S;
cin >> N >> S;
int ans = 0;
int tmp = 1;
for(int i = 0; i < N-1; i++) {
mpl(tmp,tmp);
}
int res = 1;
for(int i = 0; i < N; i++) {
for(int j = 0; j <= S.size(); j++) dp[j] = 0;
dp[S.size()] = 1;
for(int j = S.size(); j >= 1; j--) {
mpl(dp[j-1],dp[j]);
if(j < S.size()) mpl(dp[j-1],dp[j]);
if(j-1 >= i && S[j-i-1] == '1') {
mpl(dp[j-i-1],mod-dp[j]);
}
}
mpl(ans,1ll*res*(tmp+mod-dp[0])%mod);
mpl(res,res);
}
cout << ans << "\n";
}
ぷら