結果
| 問題 | No.1066 #いろいろな色 / Red and Blue and more various colors (Easy) |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2022-11-06 02:27:02 |
| 言語 | C++17(clang) (clang++ 22.1.2 + boost 1.89.0) |
| 結果 |
MLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 882 bytes |
| 記録 | |
| コンパイル時間 | 6,107 ms |
| コンパイル使用メモリ | 148,992 KB |
| 実行使用メモリ | 156,964 KB |
| 最終ジャッジ日時 | 2026-04-02 17:52:36 |
| 合計ジャッジ時間 | 7,834 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 MLE * 1 |
コンパイルメッセージ
main.cpp:31:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
31 | ll dp[N + 1];
| ^~~~~
main.cpp:31:9: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:19:7: note: declared here
19 | int N, Q;
| ^
main.cpp:37:13: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
37 | ll temp[N + 1];
| ^~~~~
main.cpp:37:13: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:19:7: note: declared here
19 | int N, Q;
| ^
2 warnings generated.
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
int main() {
int N, Q;
cin >> N >> Q;
vector<ll> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
vector<ll> B(Q);
for (int i = 0; i < Q; ++i) {
cin >> B[i];
}
ll dp[N + 1];
memset(dp, 0, sizeof(dp));
dp[0] = 1;
for (int i = 0; i < N; ++i) {
ll a = A[i];
ll temp[N + 1];
memset(temp, 0, sizeof(temp));
for (int v = 0; v < N; ++v) {
temp[v] += (a - 1) * dp[v];
temp[v + 1] += dp[v];
temp[v] %= MOD;
temp[v + 1] %= MOD;
}
memcpy(dp, temp, sizeof(temp));
}
for (int b : B) {
cout << dp[b] << endl;
}
return 0;
}
siman