結果
問題 | No.2215 Slide Subset Sum |
ユーザー |
![]() |
提出日時 | 2023-02-10 22:51:02 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,760 bytes |
コンパイル時間 | 4,178 ms |
コンパイル使用メモリ | 275,024 KB |
実行使用メモリ | 237,012 KB |
最終ジャッジ日時 | 2024-07-07 16:55:14 |
合計ジャッジ時間 | 13,203 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,126 ms
46,960 KB |
testcase_01 | TLE | - |
testcase_02 | -- | - |
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> #include <atcoder/all> using namespace std; using namespace atcoder; constexpr int mod = 998244353; void mpl(int &x,int y) { x += y; if(x >= mod) x -= mod; } vector<int>p; template <typename T> struct SegmentTree { int n,kk; vector<T> dat; T init; SegmentTree() {} SegmentTree(int N,int K,vector<int>A) { n = 1; while(n < N) { n *= 2; } kk = K; init.resize(K); init[0] = 1; dat.resize(2*n-1,init); for(int i = 0; i < N; i++) { for(int j = 0; j < K; j++) p[j] = 0; p[A[i]] = 1; p[0]++; dat[n-1+i] = p; } for(int i = n-2; i >= 0; i--) { p = convolution(dat[i*2+1],dat[i*2+2]); for(int j = K; j < p.size(); j++) { mpl(p[j-K],p[j]); } p.resize(K); dat[i] = p; } } T query(int a, int b, int k, int l, int r) { if(r <= a || b <= l) return init; if(a <= l && r <= b) return dat[k]; T vl = query(a, b, 2*k+1, l, (l+r)/2); T vr = query(a, b, 2*k+2, (l+r)/2, r); p = convolution(vl,vr); for(int j = kk; j < p.size(); j++) { mpl(p[j-kk],p[j]); } p.resize(kk); return p; } T query(int a,int b) {//[a,b) return query(a,b,0,0,n); } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N,M,K; cin >> N >> M >> K; vector<int>A(N); for(int i = 0; i < N; i++) { cin >> A[i]; } p.resize(K); SegmentTree<vector<int>>Seg(N,K,A); for(int i = 0; i+M <= N; i++) { cout << (Seg.query(i,i+M)[0]+mod-1)%mod << endl; } }