Submission #17631956


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;
}

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  int64 sum = 0;
  int ret = 1;
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
    sum += d[i] - 1;
    ret = 1LL * ret * d[i] % MOD;
  }
  trace(sum, n - 2);
  sum %= MOD;
  for (int i = 0; i < n - 2; ++i) {
    ret = 1LL * ret * (sum - i + MOD) % MOD;
  }
  cout << ret << endl;

  return 0;
}

Submission Info

Submission Time
Task F - Figures
User cuiaoxiang
Language C++ (Clang 10.0.0)
Score 800
Code Size 3400 Byte
Status AC
Exec Time 155 ms
Memory 6028 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 800 / 800
Status
AC × 4
AC × 58
Set Name Test Cases
Sample 00-Sample-00, 00-Sample-01, 00-Sample-02, 00-Sample-03
All 00-Sample-00, 00-Sample-01, 00-Sample-02, 00-Sample-03, 01-Handmade-00, 01-Handmade-01, 01-Handmade-02, 01-Handmade-03, 01-Handmade-04, 01-Handmade-05, 01-Handmade-06, 01-Handmade-07, 01-Handmade-08, 02-Small-00, 02-Small-01, 02-Small-02, 02-Small-03, 02-Small-04, 02-Small-05, 02-Small-06, 02-Small-07, 02-Small-08, 02-Small-09, 02-Small-10, 02-Small-11, 02-Small-12, 02-Small-13, 02-Small-14, 02-Small-15, 02-Small-16, 02-Small-17, 02-Small-18, 02-Small-19, 03-Large-00, 03-Large-01, 03-Large-02, 03-Large-03, 03-Large-04, 03-Large-05, 03-Large-06, 03-Large-07, 03-Large-08, 03-Large-09, 03-Large-10, 03-Large-11, 03-Large-12, 03-Large-13, 03-Large-14, 03-Large-15, 03-Large-16, 03-Large-17, 03-Large-18, 03-Large-19, 04-Tight-00, 04-Tight-01, 04-Tight-02, 04-Tight-03, 04-Tight-04
Case Name Status Exec Time Memory
00-Sample-00 AC 11 ms 5516 KB
00-Sample-01 AC 8 ms 5352 KB
00-Sample-02 AC 13 ms 5496 KB
00-Sample-03 AC 7 ms 5348 KB
01-Handmade-00 AC 138 ms 5860 KB
01-Handmade-01 AC 10 ms 5452 KB
01-Handmade-02 AC 68 ms 5976 KB
01-Handmade-03 AC 68 ms 5908 KB
01-Handmade-04 AC 155 ms 5880 KB
01-Handmade-05 AC 45 ms 5520 KB
01-Handmade-06 AC 26 ms 5572 KB
01-Handmade-07 AC 146 ms 5928 KB
01-Handmade-08 AC 17 ms 5524 KB
02-Small-00 AC 7 ms 5348 KB
02-Small-01 AC 8 ms 5496 KB
02-Small-02 AC 11 ms 5500 KB
02-Small-03 AC 7 ms 5488 KB
02-Small-04 AC 7 ms 5388 KB
02-Small-05 AC 11 ms 5484 KB
02-Small-06 AC 7 ms 5496 KB
02-Small-07 AC 9 ms 5344 KB
02-Small-08 AC 6 ms 5348 KB
02-Small-09 AC 9 ms 5384 KB
02-Small-10 AC 7 ms 5440 KB
02-Small-11 AC 13 ms 5492 KB
02-Small-12 AC 7 ms 5344 KB
02-Small-13 AC 9 ms 5520 KB
02-Small-14 AC 6 ms 5352 KB
02-Small-15 AC 12 ms 5492 KB
02-Small-16 AC 9 ms 5496 KB
02-Small-17 AC 7 ms 5500 KB
02-Small-18 AC 12 ms 5356 KB
02-Small-19 AC 8 ms 5456 KB
03-Large-00 AC 56 ms 5668 KB
03-Large-01 AC 61 ms 5596 KB
03-Large-02 AC 68 ms 5876 KB
03-Large-03 AC 11 ms 5504 KB
03-Large-04 AC 69 ms 5876 KB
03-Large-05 AC 29 ms 5496 KB
03-Large-06 AC 32 ms 5444 KB
03-Large-07 AC 68 ms 5936 KB
03-Large-08 AC 69 ms 5932 KB
03-Large-09 AC 12 ms 5500 KB
03-Large-10 AC 78 ms 5348 KB
03-Large-11 AC 137 ms 5616 KB
03-Large-12 AC 8 ms 5388 KB
03-Large-13 AC 104 ms 5652 KB
03-Large-14 AC 127 ms 5596 KB
03-Large-15 AC 28 ms 5612 KB
03-Large-16 AC 79 ms 5496 KB
03-Large-17 AC 124 ms 5764 KB
03-Large-18 AC 153 ms 5896 KB
03-Large-19 AC 109 ms 5664 KB
04-Tight-00 AC 12 ms 5500 KB
04-Tight-01 AC 19 ms 5544 KB
04-Tight-02 AC 64 ms 6028 KB
04-Tight-03 AC 22 ms 5436 KB
04-Tight-04 AC 49 ms 5540 KB