結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
コンテスト
ユーザー keijak
提出日時 2022-01-01 15:55:43
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 837 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,720 ms
コンパイル使用メモリ 279,276 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-24 22:39:46
合計ジャッジ時間 5,051 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |   scanf("%d%d", &N, &Q);
      |   ~~~~~^~~~~~~~~~~~~~~~
main.cpp:18:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |     scanf("%d", &a);
      |     ~~~~~^~~~~~~~~~
main.cpp:32:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |     scanf("%d", &b);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #
raw source code

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <atcoder/convolution>
#include <atcoder/modint>
#define REP(i, n) for (int i = 0, REP_N_ = int(n); i < REP_N_; ++i)
using namespace std;
using Mint = atcoder::modint998244353;

int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);

  deque<vector<Mint>> q;
  REP(i, N) {
    int a;
    scanf("%d", &a);
    q.push_back(vector<Mint>{Mint(a - 1), Mint(1)});
  }
  while (q.size() > 1) {
    auto r = atcoder::convolution(move(q[0]), move(q[1]));
    if (int(r.size()) > N + 1) r.resize(N + 1);
    while (r.back() == 0) r.pop_back();
    q.pop_front();
    q.pop_front();
    q.push_back(move(r));
  }
  const auto &f = q.front();
  REP(i, Q) {
    int b;
    scanf("%d", &b);
    printf("%u\n", f[b].val());
  }
}
0