結果

問題 No.2279 OR Insertion
ユーザー lddlinanlddlinan
提出日時 2023-04-21 23:59:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 1,245 bytes
コンパイル時間 617 ms
コンパイル使用メモリ 84,680 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 09:48:41
合計ジャッジ時間 3,778 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 11 ms
5,376 KB
testcase_03 AC 6 ms
5,376 KB
testcase_04 AC 76 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 31 ms
5,376 KB
testcase_07 AC 32 ms
5,376 KB
testcase_08 AC 11 ms
5,376 KB
testcase_09 AC 43 ms
5,376 KB
testcase_10 AC 73 ms
5,376 KB
testcase_11 AC 9 ms
5,376 KB
testcase_12 AC 56 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 5 ms
5,376 KB
testcase_15 AC 36 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 29 ms
5,376 KB
testcase_18 AC 47 ms
5,376 KB
testcase_19 AC 63 ms
5,376 KB
testcase_20 AC 32 ms
5,376 KB
testcase_21 AC 24 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 80 ms
5,376 KB
testcase_33 AC 80 ms
5,376 KB
testcase_34 AC 79 ms
5,376 KB
testcase_35 AC 79 ms
5,376 KB
testcase_36 AC 83 ms
5,376 KB
testcase_37 AC 81 ms
5,376 KB
testcase_38 AC 81 ms
5,376 KB
testcase_39 AC 80 ms
5,376 KB
testcase_40 AC 82 ms
5,376 KB
testcase_41 AC 81 ms
5,376 KB
testcase_42 AC 95 ms
5,376 KB
testcase_43 AC 96 ms
5,376 KB
testcase_44 AC 94 ms
5,376 KB
testcase_45 AC 66 ms
5,376 KB
testcase_46 AC 65 ms
5,376 KB
testcase_47 AC 64 ms
5,376 KB
testcase_48 AC 96 ms
5,376 KB
testcase_49 AC 61 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;
class mypcmp {
public:
    bool operator()(const int& a, const int& b) {
        return a<b;
    }
};


#define MOD 998244353
char ib[4004];
int dp[4004];
int bb[4004];
int main() {
    int n, i, ni, c;
    LL b, s1, r, t;
    scanf("%d %s", &n, ib);
    bb[0]=1; for (i=1; i<=n; i++) bb[i]=(bb[i-1]*2)%MOD;
    r=0;
    for (b=0; b<n; b++) {
        dp[n]=0;
        s1=0;
        for (i=n-1; i>=0; i--) {
            if (ib[i]=='1') {
                ni=i+b+1;
                if (ni<=n) {
                    s1-=dp[ni];
                    c=n-ni-1; if (c<0) c=0;
                    s1+=bb[c];
                    s1%=MOD; if (s1<0) s1+=MOD;
                }
            }
            dp[i]=s1;
            // printf("dp %d,%d: %lld\n", b, i, s1);
            s1+=dp[i]; s1%=MOD;
        }
        t=dp[0]; t*=bb[b]; t%=MOD;
        r+=t; r%=MOD;
    }
    printf("%lld\n", r);
    return 0;
}
0