結果

問題 No.2215 Slide Subset Sum
ユーザー maksimmaksim
提出日時 2023-02-11 00:38:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,496 bytes
コンパイル時間 1,594 ms
コンパイル使用メモリ 169,952 KB
実行使用メモリ 11,176 KB
最終ジャッジ日時 2023-09-22 01:19:26
合計ジャッジ時間 8,355 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int32_t main()’ 内:
main.cpp:57:18: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   57 |             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];for(int i=0;i<n;++i) cin>>a[i];
    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/3);
        for(int l=i;l>=i-m;l-=3)
        {
            v.push_back({l,u});
            if(l>=1) add(u,a[l-1]); if(l>=2) add(u,a[l-2]);if(l>=3) add(u,a[l-3]);
        }
        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=(r-i+m)/3;
            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<<' ';
    }
    return 0;
}
0