結果

問題 No.2215 Slide Subset Sum
ユーザー maksimmaksim
提出日時 2023-02-11 00:54:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,484 bytes
コンパイル時間 1,879 ms
コンパイル使用メモリ 169,448 KB
実行使用メモリ 58,916 KB
最終ジャッジ日時 2023-09-22 01:24:57
合計ジャッジ時間 16,721 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 949 ms
6,768 KB
testcase_02 RE -
testcase_03 AC 608 ms
6,540 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 2 ms
4,380 KB
testcase_08 RE -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 AC 946 ms
6,496 KB
testcase_40 AC 108 ms
6,452 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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/3+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