結果

問題 No.1549 [Cherry 2nd Tune] BANning Tuple
ユーザー googol_S0googol_S0
提出日時 2021-06-11 22:12:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 405 ms / 4,000 ms
コード長 1,453 bytes
コンパイル時間 5,034 ms
コンパイル使用メモリ 286,976 KB
実行使用メモリ 10,080 KB
最終ジャッジ日時 2023-08-21 12:46:18
合計ジャッジ時間 12,945 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,376 KB
testcase_01 AC 17 ms
4,380 KB
testcase_02 AC 128 ms
4,380 KB
testcase_03 AC 304 ms
6,540 KB
testcase_04 AC 305 ms
6,768 KB
testcase_05 AC 295 ms
6,316 KB
testcase_06 AC 292 ms
6,192 KB
testcase_07 AC 395 ms
9,736 KB
testcase_08 AC 400 ms
10,080 KB
testcase_09 AC 399 ms
9,936 KB
testcase_10 AC 394 ms
9,836 KB
testcase_11 AC 401 ms
9,824 KB
testcase_12 AC 400 ms
9,836 KB
testcase_13 AC 398 ms
9,740 KB
testcase_14 AC 400 ms
9,948 KB
testcase_15 AC 395 ms
9,780 KB
testcase_16 AC 396 ms
9,844 KB
testcase_17 AC 405 ms
9,608 KB
testcase_18 AC 404 ms
9,736 KB
testcase_19 AC 82 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
using mint=modint998244353;
ll M=4001;
vector<mint> op(vector<mint> a,vector<mint> b){
  vector<mint> c=convolution(a,b);
  vector<mint> r(min(M,(ll)(c.size())),0);
  for(ll i=0;i<(ll)(r.size());i++){
    r[i]=c[i];
  }
  return r;
}
vector<mint> e(){
  vector<mint> r(1,1);
  return r;
}
int main(){
  ll N,Q;
  cin>>N>>Q;
  vector<ll> K(Q);
  vector<vector<ll>> que(Q,vector<ll>(4));
  for(ll i=0;i<Q;i++){
    cin>>K[i];
    K[i]--;
    for(ll j=0;j<4;j++){
      cin>>que[i][j];
    }
  }
  vector<ll> X=K;
  sort(X.begin(),X.end());
  vector<ll> y(1,X[0]);
  ll L=X.size();
  for(ll i=1;i<L;i++){
    if(X[i]!=X[i-1]){
      y.push_back(X[i]);
    }
  }
  X=y;
  L=X.size();
  unordered_map<ll,ll> Y;
  for(ll i=0;i<L;i++){
    Y[X[i]]=i;
  }
  vector<vector<mint>> Z(L,vector<mint>(M,1));
  vector<vector<mint>> x(L,vector<mint>(M,1));
  segtree<vector<mint>,op,e> seg(x);
  vector<mint> p(M,1);
  vector<mint> q(1,1);
  ll R=N-L;
  while(R){
    if(R&1){
      q=op(p,q);
    }
    p=op(p,p);
    R>>=1;
  }
  ll I;
  for(ll i=0;i<Q;i++){
    I=Y[K[i]];
    for(ll j=que[i][0];j<=que[i][1];j++){
      Z[I][j]=0;
    }
    seg.set(I,Z[I]);
    vector<mint> A=op(seg.all_prod(),q);
    mint ANS=0;
    for(ll j=que[i][2];j<=que[i][3];j++){
      if((ll)(A.size())>j){
        ANS+=A[j];
      }
    }
    cout<<ANS.val()<<"\n";
  }
}
0