結果

問題 No.1068 #いろいろな色 / Red and Blue and more various colors (Hard)
ユーザー keijak
提出日時 2022-01-01 17:20:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 463 ms / 3,500 ms
コード長 455 bytes
コンパイル時間 4,817 ms
コンパイル使用メモリ 261,856 KB
最終ジャッジ日時 2025-01-27 08:21:06
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using Mint=atcoder::modint998244353;
int main(){
  int N,Q;cin>>N>>Q;
  deque<vector<Mint>>q;
  for (long long i=0,a;i<N;++i)cin>>a,q.push_back(vector<Mint>{a-1,1});
  while(q.size()>1){
    auto r=atcoder::convolution(q[0],q[1]);
    if(r.size()>N+1)r.resize(N+1);
    q.pop_front();q.pop_front();q.push_back(r);
  }
  for (int i=0,b;i<Q;++i)cin>>b,printf("%u\n",q.front()[b].val());
}
0