結果
| 問題 | 
                            No.1068 #いろいろな色 / Red and Blue and more various colors (Hard)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-06-05 22:39:55 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 331 ms / 3,500 ms | 
| コード長 | 950 bytes | 
| コンパイル時間 | 3,843 ms | 
| コンパイル使用メモリ | 234,832 KB | 
| 最終ジャッジ日時 | 2025-01-29 18:38:13 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 29 | 
ソースコード
#include<bits/stdc++.h>
#include<atcoder/convolution>
#include<atcoder/modint>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
const long long MOD = 998244353;
void solve(){
    int n, q;
    cin >> n >> q;
    vector<vector<mint>> poly(n, vector<mint>(2));
    long long a;
    queue<int> que;
    for(int i = 0; i < n; i++){
        que.push(i);
        cin >> a;
        a--;
        a %= MOD;
        poly[i][0] = a;
        poly[i][1] = 1;
    }
    while(que.size() >= 2){
        int i = que.front();
        que.pop();
        int j = que.front();
        que.pop();
        poly[i] = convolution(poly[i], poly[j]);
        que.push(i);
    }
    vector<mint> F = poly[que.front()];
    int b;
    for(int i = 0; i < q; i++){
        cin >> b;
        cout << F[b].val() << "\n";
    }
}
int main(){
    cin.tie(0)->sync_with_stdio(0);
    int t;
    t = 1;
    // cin >> t;
    while(t--) solve();
}