結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー hedwig100hedwig100
提出日時 2020-05-29 23:32:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,005 bytes
コンパイル時間 1,616 ms
コンパイル使用メモリ 170,656 KB
実行使用メモリ 285,184 KB
最終ジャッジ日時 2024-04-24 01:49:59
合計ジャッジ時間 4,512 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 135 ms
105,088 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 MLE -
testcase_11 AC 74 ms
60,160 KB
testcase_12 AC 55 ms
46,080 KB
testcase_13 AC 76 ms
62,080 KB
testcase_14 AC 81 ms
65,408 KB
testcase_15 MLE -
testcase_16 AC 33 ms
27,648 KB
testcase_17 AC 38 ms
32,128 KB
testcase_18 MLE -
testcase_19 AC 70 ms
58,112 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 MLE -
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PL;
typedef pair<int,int> P;
const int INF = 1e9;
const ll MOD = 998244353;
const double eps = 1e-6;

ll modpow(ll N,ll K,ll mod = MOD) {
    ll ret = 1;
    while (K > 0) {
        if (K&1) {
            ret *= N;
            ret %= mod;
        }
        K >>= 1;
        N *= N;
        N %= mod;
    }
    return ret;
}

int main() {
    int N,Q; cin >> N >> Q;
    vector<ll> A(N);
    rep(i,N) {
        int a; cin >> a; A[i] = a - 1;
    }
    vector<int> B(Q);
    rep(i,Q) cin >> B[i];

    vector<vector<ll>> dp(N + 1,vector<ll>(N,0));
    dp[0][N - 1] = 1;
    dp[1] = A;
    rep(i,N - 1) dp[1][i + 1] = (dp[1][i + 1] + dp[1][i])%MOD;
    for (int i = 2;i < N + 1;i++){
        for (int j = 1;j < N;j++){
            dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 1] * A[j]) % MOD;
        }
    }
    rep(i,Q){
        cout << dp[N - B[i]][N - 1] << endl;
    }
}
0