結果

問題 No.2215 Slide Subset Sum
ユーザー maksimmaksim
提出日時 2023-02-11 00:55:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 948 ms / 3,000 ms
コード長 1,482 bytes
コンパイル時間 1,630 ms
コンパイル使用メモリ 169,580 KB
実行使用メモリ 163,904 KB
最終ジャッジ日時 2023-09-22 01:25:42
合計ジャッジ時間 16,645 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
6,512 KB
testcase_01 AC 948 ms
6,620 KB
testcase_02 AC 596 ms
6,584 KB
testcase_03 AC 600 ms
6,532 KB
testcase_04 AC 599 ms
9,688 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 469 ms
77,320 KB
testcase_18 AC 458 ms
67,236 KB
testcase_19 AC 606 ms
8,684 KB
testcase_20 AC 335 ms
85,188 KB
testcase_21 AC 572 ms
24,336 KB
testcase_22 AC 333 ms
91,392 KB
testcase_23 AC 312 ms
147,460 KB
testcase_24 AC 307 ms
148,224 KB
testcase_25 AC 316 ms
132,076 KB
testcase_26 AC 334 ms
92,160 KB
testcase_27 AC 21 ms
4,376 KB
testcase_28 AC 20 ms
25,592 KB
testcase_29 AC 36 ms
7,196 KB
testcase_30 AC 258 ms
5,256 KB
testcase_31 AC 105 ms
63,584 KB
testcase_32 AC 49 ms
5,688 KB
testcase_33 AC 352 ms
20,496 KB
testcase_34 AC 244 ms
66,092 KB
testcase_35 AC 46 ms
8,852 KB
testcase_36 AC 62 ms
27,692 KB
testcase_37 AC 305 ms
163,884 KB
testcase_38 AC 101 ms
163,904 KB
testcase_39 AC 940 ms
6,548 KB
testcase_40 AC 115 ms
6,496 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 475 ms
85,328 KB
testcase_43 AC 607 ms
14,444 KB
testcase_44 AC 604 ms
14,576 KB
testcase_45 AC 317 ms
124,480 KB
testcase_46 AC 318 ms
124,600 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int32_t main()’ 内:
main.cpp:58:18: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   58 |             auto [l,u]=v[pos];
      |                  ^

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define int long long
const int p=998244353;
int n,m,k;
array<int,100> v;
void add(array<int,100>& u,int x)
{
    for(int i=0;i<k;++i)
    {
        v[(i+x)%k]=u[i];
    }
    for(int i=0;i<k;++i)
    {
        u[i]+=v[i];
        if(u[i]>=p) u[i]-=p;
    }
}
int f(array<int,100> u,array<int,100> v)
{
    int ans=u[0]*v[0];ans%=p;
    for(int i=1;i<k;++i)
    {
        ans+=u[i]*v[k-i];ans%=p;
    }
    return ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m>>k;
    int a[n+1];for(int i=0;i<n;++i) {cin>>a[i];} a[n]=0;
    int ans[n]={0};
    for(int i=m;i<=n;i+=m)
    {
        array<int,100> u;
        for(int i=0;i<100;++i) u[i]=0;
        u[0]=1;
        vector<pair<int,array<int,100> > > v(m+1);
        int sz=0;
        for(int l=i;l>=max(0LL,i-m);l--)
        {
            v[sz++]={l,u};
            if(l>=1) add(u,a[l-1]);
        }
        array<int,100> d,d1;
        for(int i=0;i<100;++i) d1[i]=0;
        d1[0]=1;
        for(int r=i;r<=min(n,i+m);++r)
        {
            if(r!=i)
            {
                add(d1,a[r-1]);
            }
            d=d1;
            int pos=(i-r+m);
            auto [l,u]=v[pos];
            while(l>r-m)
            {
                add(d,a[l-1]);
                --l;
            }
            ans[l]=f(d,u);
        }
    }
    for(int i=0;i<=n-m;++i)
    {
        cout<<(ans[i]+p-1)%p<<'\n';
    }
    return 0;
}
0