結果

問題 No.2215 Slide Subset Sum
ユーザー maksimmaksim
提出日時 2023-02-10 23:42:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,322 bytes
コンパイル時間 3,628 ms
コンパイル使用メモリ 193,440 KB
実行使用メモリ 43,524 KB
最終ジャッジ日時 2023-09-22 00:39:37
合計ジャッジ時間 50,047 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
8,828 KB
testcase_01 AC 104 ms
9,040 KB
testcase_02 AC 2,561 ms
22,392 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 AC 5 ms
8,264 KB
testcase_06 AC 5 ms
8,080 KB
testcase_07 AC 5 ms
8,264 KB
testcase_08 AC 6 ms
8,012 KB
testcase_09 AC 5 ms
8,216 KB
testcase_10 AC 5 ms
8,000 KB
testcase_11 AC 5 ms
8,188 KB
testcase_12 AC 6 ms
8,044 KB
testcase_13 AC 6 ms
8,212 KB
testcase_14 AC 6 ms
8,060 KB
testcase_15 AC 5 ms
8,036 KB
testcase_16 AC 7 ms
8,072 KB
testcase_17 AC 2,332 ms
35,912 KB
testcase_18 AC 2,563 ms
37,888 KB
testcase_19 TLE -
testcase_20 AC 2,147 ms
34,208 KB
testcase_21 TLE -
testcase_22 AC 2,007 ms
32,848 KB
testcase_23 AC 644 ms
19,036 KB
testcase_24 AC 623 ms
18,844 KB
testcase_25 AC 1,025 ms
23,208 KB
testcase_26 AC 1,999 ms
32,572 KB
testcase_27 AC 81 ms
9,692 KB
testcase_28 AC 21 ms
9,676 KB
testcase_29 AC 158 ms
9,968 KB
testcase_30 AC 1,265 ms
13,092 KB
testcase_31 AC 81 ms
10,660 KB
testcase_32 AC 242 ms
10,440 KB
testcase_33 AC 1,739 ms
34,312 KB
testcase_34 AC 804 ms
28,380 KB
testcase_35 AC 139 ms
16,948 KB
testcase_36 AC 205 ms
11,016 KB
testcase_37 AC 207 ms
14,292 KB
testcase_38 AC 25 ms
14,272 KB
testcase_39 AC 104 ms
8,812 KB
testcase_40 AC 40 ms
9,000 KB
testcase_41 AC 4 ms
8,272 KB
testcase_42 AC 2,153 ms
34,260 KB
testcase_43 AC 2,307 ms
42,464 KB
testcase_44 AC 2,305 ms
42,268 KB
testcase_45 AC 1,215 ms
24,992 KB
testcase_46 AC 1,210 ms
25,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>

using namespace std;
const int p=998244353;
const int maxn=2e5+5;
const int maxn1=100;
int sq=30;
int n,m,k;
int a[maxn];
vector<int> ord[maxn];
map<pair<int,int>,array<int,100> > u;
int cyc=1;
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;
    }
}
array<int,100> merg(array<int,100> u,array<int,100> v)
{
    __int128 res[100]={0};
    for(int i=0;i<100;++i) res[i]=0;
    for(int i=0;i<k;++i)
    {
        if(!v[i]) continue;
        for(int j=0;i+j<k;++j)
        {
            res[i+j]+=(v[i]*1LL*u[j]);
        }
        for(int j=k-i;j<k;++j)
        {
            res[i+j-k]+=(v[i]*1LL*u[j]);
        }
    }
    array<int,100> res1;for(int i=0;i<100;++i) res1[i]=0;
    for(int i=0;i<k;++i) res1[i]=res[i]%p;
    return res1;
}
int f2(int l,int r)
{
    int o=1;
    while(((r-1)/o)!=(l/o)) o*=2;
    o/=2;
    int pos=o*(l/o+1);
    return pos;
}
array<int,100> f(int l,int r,int de)
{
    if(u.count({l,r})) return u[{l,r}];
    if(r-l<sq) return {};
    if(de==0)
    {
    int l1=((l+sq)/sq)*sq;int r1=((r-1)/sq)*sq;
    if(l1>r1)
    {
        l1=l;r1=l;
    }
    ++cyc;
    array<int,100> h;
    if(r1-l1>sq)
    {
        h=f(l1,r1,1);
    }
    else
    {
        for(int i=0;i<100;++i) h[i]=0;
        h[0]=1;
        for(int i=l1;i<r1;++i) add(h,a[i]);
    }
    for(int i=l;i<l1;++i)
    {
        add(h,a[i]);
    }
    for(int i=r1;i<r;++i)
    {
        add(h,a[i]);
    }
    return h;
    }
    else
    {
        int pos=f2(l,r);
        array<int,100> h;
    if(pos-l>sq)
    {
        h=f(l,pos,1);
    }
    else
    {
        for(int i=0;i<100;++i) h[i]=0;
        h[0]=1;
        for(int i=l;i<pos;++i) add(h,a[i]);
    }
    if(r-pos>sq)
    {
        h=merg(h,f(pos,r,1));
    }
    else
    {
        for(int i=pos;i<r;++i) add(h,a[i]);
    }
    u[{l,r}]=h;
    return h;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m>>k;
    for(int i=0;i<n;++i) cin>>a[i];
    sq=min(sq,m);
    for(int i=0;i<=n-m;++i)
    {
        //f(i,i+m,0);
        cout<<((f(i,i+m,0)[0]-1)%p+p)%p<<'\n';
    }
    return 0;
}
0