結果
問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
ユーザー |
|
提出日時 | 2020-05-30 15:20:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 698 bytes |
コンパイル時間 | 2,124 ms |
コンパイル使用メモリ | 184,444 KB |
実行使用メモリ | 284,800 KB |
最終ジャッジ日時 | 2024-11-07 17:50:31 |
合計ジャッジ時間 | 5,568 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 MLE * 6 |
ソースコード
#pragma GCC optimize("O3", "unroll-loops") #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double constexpr ll mod = 998244353LL; int main(void){ int N, Q; cin >> N >> Q; vector<int> A(N); for (int i = 0; i < N; ++i) cin >> A[i]; vector<vector<ll>> DP(N + 1, vector<ll>(N + 1, 0LL)); DP[0][0] = 1LL; for (int i = 0; i < N; ++i){ for (int j = 0; j < N; ++j){ DP[i + 1][j] = (DP[i + 1][j] + DP[i][j] * (A[i] - 1) % mod) % mod; DP[i + 1][j + 1] = (DP[i + 1][j + 1] + DP[i][j]) % mod; } } while (Q--){ int B; cin >> B; cout << DP[N][B] << endl; } return 0; }