結果
問題 | No.1066 #いろいろな色 / Red and Blue and more various colors (Easy) |
ユーザー | toma |
提出日時 | 2020-05-29 22:01:37 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,763 bytes |
コンパイル時間 | 1,866 ms |
コンパイル使用メモリ | 173,072 KB |
実行使用メモリ | 284,928 KB |
最終ジャッジ日時 | 2024-11-06 04:41:25 |
合計ジャッジ時間 | 4,723 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,820 KB |
testcase_02 | AC | 2 ms
6,820 KB |
testcase_03 | AC | 2 ms
6,816 KB |
testcase_04 | AC | 2 ms
6,820 KB |
testcase_05 | AC | 2 ms
6,820 KB |
testcase_06 | AC | 2 ms
6,820 KB |
testcase_07 | AC | 2 ms
6,816 KB |
testcase_08 | AC | 110 ms
105,216 KB |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | MLE | - |
testcase_11 | AC | 61 ms
60,288 KB |
testcase_12 | AC | 47 ms
46,080 KB |
testcase_13 | AC | 62 ms
62,080 KB |
testcase_14 | AC | 66 ms
65,280 KB |
testcase_15 | MLE | - |
testcase_16 | AC | 29 ms
27,776 KB |
testcase_17 | AC | 34 ms
32,000 KB |
testcase_18 | MLE | - |
testcase_19 | AC | 57 ms
57,984 KB |
testcase_20 | AC | 2 ms
6,816 KB |
testcase_21 | MLE | - |
testcase_22 | AC | 3 ms
6,816 KB |
testcase_23 | AC | 2 ms
6,816 KB |
testcase_24 | AC | 2 ms
6,820 KB |
testcase_25 | MLE | - |
testcase_26 | MLE | - |
ソースコード
#include"bits/stdc++.h" using namespace std; #define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++) #define rep(i,n) REP((i),0,(n)) using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using tp3 = tuple<int, int, int>; using Mat = vector<vector<ll>>; constexpr int INF = 1 << 28; constexpr ll INFL = 1ll << 60; constexpr int dh[4] = { 0,1,0,-1 }; constexpr int dw[4] = { -1,0,1,0 }; bool isin(const int H, const int W, const int h, const int w) { return 0 <= h && h < H && 0 <= w && w < W; } struct ModInt { static const ll MOD = 998244353; // constructors etc ModInt() :num(1ll) {} ModInt(ll num_) :num(num_%MOD) {} ModInt(const ModInt& modint) :num(modint.num%MOD) {} ll get()const { return num; } // operator etc // operator ll() const { return num; } // ll operator*() { return num; } ModInt& operator+=(const ModInt& r) { (num += r.num) %= MOD; return *this; } ModInt& operator-=(const ModInt& r) { (num += -r.num + MOD) %= MOD; return *this; } ModInt& operator*=(const ModInt& r) { (num *= r.num) %= MOD; return *this; } ModInt& operator/=(const ModInt& r) { (num *= r.inv().num) %= MOD; return *this; } ModInt pow(const ModInt& r)const { ll res = 1; ll x = num; ll n = r.num; while (n > 0) { if (n & 1)res = (res*x) % MOD; x = (x*x) % MOD; n >>= 1; } return res; } ModInt inv()const { return this->pow(MOD - 2); } ModInt operator+(const ModInt& r)const { return ModInt(*this) += r; } ModInt operator-(const ModInt& r)const { return ModInt(*this) -= r; } ModInt operator*(const ModInt& r)const { return ModInt(*this) *= r; } ModInt operator/(const ModInt& r)const { return ModInt(*this) /= r; } ModInt operator+(const ll& r)const { return *this + ModInt(r); } ModInt operator-(const ll& r)const { return *this - ModInt(r); } ModInt operator*(const ll& r)const { return *this * ModInt(r); } ModInt operator/(const ll& r)const { return *this / ModInt(r); } private: ll num; }; ostream& operator<<(ostream& stream, const ModInt& val) { stream << val.get(); return stream; } // ============ template finished ============ int main() { int N, Q; cin >> N >> Q; vector<int> A(N), B(Q); rep(i, N)cin >> A[i]; rep(i, Q)cin >> B[i]; vector<vector<ll>> dp(N, vector<ll>(N + 1, 0)); dp[0][0] = A[0] - 1; dp[0][1] = 1; const ll MOD = 998244353; REP(i, 1, N) { dp[i][0] = dp[i - 1][0] * (A[i] - 1) % MOD; REP(j, 1, N + 1) { dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j] * (A[i] - 1)) % MOD; } } for (auto b : B) { cout << dp.back()[b] << endl; } return 0; }