Submission #17627154


Source Code Expand

Copy
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 998244353;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 2e5 + 10;
int fact[N], ifact[N], inv[N];

struct comb_init {
  comb_init() {
    inv[1] = 1;
    for (int i = 2; i < N; ++i) {
      inv[i] = (MOD - MOD / i) * (int64)inv[MOD % i] % MOD;
    }
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < N; ++i) {
      fact[i] = (int64)fact[i - 1] * i % MOD;
      ifact[i] = (int64)ifact[i - 1] * inv[i] % MOD;
    }
  }
} comb_init_;

int64 comb(int n, int m) {
  if (n < m || m < 0) return 0;
  return (int64)fact[n] * ifact[m] % MOD * ifact[n - m] % MOD;
}

void add(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), p(n, 1), sum(m + 1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    for (int k = 0; k <= m; ++k) {
      add(sum[k], p[i]);
      p[i] = 1LL * p[i] * a[i] % MOD;
    }
  }

  vector<int> ret(m + 1);
  for (int k = 1; k <= m; ++k) {
    for (int i = 0; i <= k; ++i) {
      int j = k - i;
      int cur = 1LL * sum[i] * sum[j] % MOD * comb(i + j, i) % MOD;
      add(ret[k], cur);
    }
  }
  int64 p2 = 1;
  int64 inv2 = (MOD + 1) / 2;
  for (int k = 1; k <= m; ++k) {
    p2 = p2 * 2 % MOD;
    ret[k] -= sum[k] * p2 % MOD;
    if (ret[k] < 0) ret[k] += MOD;
    cout << ret[k] * inv2 % MOD << '\n';
  }

  return 0;
}

Submission Info

Submission Time
Task D - Powers
User cuiaoxiang
Language C++ (Clang 10.0.0)
Score 600
Code Size 3814 Byte
Status AC
Exec Time 479 ms
Memory 6844 KB

Compile Error

./Main.cpp:78:11: warning: unused variable 'INF' [-Wunused-const-variable]
const int INF = 1 << 29;
          ^
1 warning generated.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 30
Set Name Test Cases
Sample 00_sample_01, 00_sample_02, 00_sample_03
All 00_sample_01, 00_sample_02, 00_sample_03, 10_small_01, 10_small_02, 10_small_03, 10_small_04, 10_small_05, 10_small_06, 10_small_07, 10_small_08, 10_small_09, 10_small_10, 20_random_01, 20_random_02, 20_random_03, 20_random_04, 20_random_05, 20_random_06, 20_random_07, 20_random_08, 20_random_09, 20_random_10, 30_max_01, 30_max_02, 30_max_03, 30_max_04, 30_max_05, 31_max_01, 31_max_02
Case Name Status Exec Time Memory
00_sample_01 AC 12 ms 5456 KB
00_sample_02 AC 10 ms 5520 KB
00_sample_03 AC 8 ms 5496 KB
10_small_01 AC 8 ms 5384 KB
10_small_02 AC 11 ms 5384 KB
10_small_03 AC 8 ms 5552 KB
10_small_04 AC 12 ms 5376 KB
10_small_05 AC 8 ms 5376 KB
10_small_06 AC 8 ms 5356 KB
10_small_07 AC 7 ms 5384 KB
10_small_08 AC 8 ms 5504 KB
10_small_09 AC 8 ms 5496 KB
10_small_10 AC 16 ms 5460 KB
20_random_01 AC 162 ms 5648 KB
20_random_02 AC 190 ms 5652 KB
20_random_03 AC 39 ms 5744 KB
20_random_04 AC 206 ms 5940 KB
20_random_05 AC 157 ms 6304 KB
20_random_06 AC 311 ms 6256 KB
20_random_07 AC 132 ms 5952 KB
20_random_08 AC 302 ms 6084 KB
20_random_09 AC 150 ms 6464 KB
20_random_10 AC 203 ms 6712 KB
30_max_01 AC 479 ms 6844 KB
30_max_02 AC 479 ms 6728 KB
30_max_03 AC 479 ms 6844 KB
30_max_04 AC 475 ms 6744 KB
30_max_05 AC 468 ms 6680 KB
31_max_01 AC 458 ms 6608 KB
31_max_02 AC 463 ms 6604 KB