結果
問題 | No.2215 Slide Subset Sum |
ユーザー |
|
提出日時 | 2023-02-10 23:01:28 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,133 bytes |
コンパイル時間 | 1,460 ms |
コンパイル使用メモリ | 177,504 KB |
実行使用メモリ | 814,080 KB |
最終ジャッジ日時 | 2024-07-07 17:04:36 |
合計ジャッジ時間 | 8,625 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,116 ms
6,812 KB |
testcase_01 | AC | 252 ms
6,944 KB |
testcase_02 | MLE | - |
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 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long const int p=998244353; const int maxn=2e5+5; const int maxn1=100; int sq=30; int n,m,k; int a[maxn]; map<pair<int,int>,array<int,100> > u; int cyc=1; array<int,100> add(array<int,100> u,int x) { array<int,100> v; for(int i=0;i<100;++i) v[i]=0; for(int i=0;i<100;++i) { v[i]+=u[i]; v[(i+x)%k]+=u[i]; } for(int i=0;i<100;++i) if(v[i]>=p) v[i]-=p; return v; } array<int,100> merg(array<int,100> u,array<int,100> v) { array<int,100> res; for(int i=0;i<100;++i) res[i]=0; for(int i=0;i<100;++i) { for(int j=0;j<100;++j) { res[i+j]+=(u[i]*v[j]); if(res[i+j]>6e18) res[i+j]%=p; } } for(int i=0;i<100;++i) res[i]%=p; return res; } int f2(int l,int r) { int o=1; while((r/o)!=(l/o)) o*=2; o/=2; return o*(l/o+1); } 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) h=add(h,a[i]); } for(int i=l;i<l1;++i) { h=add(h,a[i]); } for(int i=r1;i<r;++i) { h=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) h=add(h,a[i]); } if(r-pos>sq) { h=merg(h,f(pos,r,1)); } else { for(int i=pos;i<r;++i) h=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) { cout<<((f(i,i+m,0)[0]-1)%p+p)%p<<'\n'; } return 0; }