結果

問題 No.2215 Slide Subset Sum
ユーザー maksimmaksim
提出日時 2023-02-11 00:48:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,521 bytes
コンパイル時間 1,763 ms
コンパイル使用メモリ 168,616 KB
実行使用メモリ 53,700 KB
最終ジャッジ日時 2023-09-22 01:22:51
合計ジャッジ時間 20,007 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
6,508 KB
testcase_01 AC 1,384 ms
6,568 KB
testcase_02 AC 817 ms
6,500 KB
testcase_03 AC 827 ms
6,648 KB
testcase_04 AC 813 ms
7,596 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 559 ms
30,360 KB
testcase_18 AC 570 ms
27,064 KB
testcase_19 AC 820 ms
7,132 KB
testcase_20 AC 433 ms
32,576 KB
testcase_21 AC 750 ms
12,384 KB
testcase_22 AC 417 ms
34,608 KB
testcase_23 AC 303 ms
53,272 KB
testcase_24 AC 301 ms
53,700 KB
testcase_25 AC 331 ms
48,436 KB
testcase_26 AC 415 ms
34,828 KB
testcase_27 AC 27 ms
4,380 KB
testcase_28 AC 17 ms
10,828 KB
testcase_29 AC 47 ms
4,864 KB
testcase_30 AC 357 ms
5,136 KB
testcase_31 AC 94 ms
23,912 KB
testcase_32 AC 63 ms
4,380 KB
testcase_33 AC 449 ms
10,776 KB
testcase_34 AC 273 ms
26,028 KB
testcase_35 AC 54 ms
5,708 KB
testcase_36 AC 69 ms
11,720 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 1,393 ms
6,736 KB
testcase_40 AC 109 ms
6,480 KB
testcase_41 WA -
testcase_42 AC 431 ms
32,528 KB
testcase_43 AC 793 ms
9,068 KB
testcase_44 AC 795 ms
9,288 KB
testcase_45 AC 349 ms
45,604 KB
testcase_46 AC 350 ms
45,632 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];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+1);
        int sz=0;
        for(int l=i;l>=max(0LL,i-m);l-=3)
        {
            v[sz++]={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=(i-r+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<<'\n';
    }
    return 0;
}
0