結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー hir355hir355
提出日時 2020-05-29 21:59:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,467 bytes
コンパイル時間 1,631 ms
コンパイル使用メモリ 165,424 KB
実行使用メモリ 284,928 KB
最終ジャッジ日時 2024-04-23 22:20:23
合計ジャッジ時間 5,170 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 165 ms
119,424 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 MLE -
testcase_11 AC 99 ms
70,912 KB
testcase_12 AC 77 ms
55,552 KB
testcase_13 AC 102 ms
73,088 KB
testcase_14 AC 107 ms
76,672 KB
testcase_15 MLE -
testcase_16 AC 48 ms
34,816 KB
testcase_17 AC 55 ms
39,936 KB
testcase_18 MLE -
testcase_19 AC 97 ms
68,736 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 MLE -
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define INF_LL 100000000000000000LL
#define INF 200000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<double, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

ll dp[6001][6001];

signed main() {
    int n, q;
    cin >> n >> q;
    vi a(n);
    rep(i, n) cin >> a[i];
    dp[0][0] = 1;
    rep(i, n) rep(j, n) {
        dp[i + 1][j + 1] += dp[i][j];
        dp[i + 1][j] += dp[i][j] * (a[i] - 1);
        dp[i + 1][j + 1] %= MOD;
        dp[i + 1][j] %= MOD;
    }
    rep(i, q) {
        int b;
        cin >> b;
        cout << dp[n][b] << endl;
    }
    return 0;
}
0