結果

問題 No.1682 Unfair Game
ユーザー hitonanodehitonanode
提出日時 2021-08-08 18:08:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 905 bytes
コンパイル時間 5,964 ms
コンパイル使用メモリ 215,500 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 06:20:54
合計ジャッジ時間 6,946 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Validator
#include <atcoder/modint>
#include <iostream>
#include <vector>
#include "testlib.h"
using namespace std;
using mint = atcoder::modint1000000007;

int main(int argc, char **argv) {
    registerValidation(argc, argv);
    int N = inf.readInt(1, 100);
    inf.readEoln();
    vector<int> P = inf.readInts(N, 0, 100);
    inf.readEoln();
    inf.readEof();
    vector<mint> dp(3); // 0: even-dominant, 1: equal, 2: odd-dominant (1 は不要だが…)
    dp[0] = 1;
    for (auto p : P) {
        vector<mint> nxtdp = dp;
        if (p < 50) {
            nxtdp[0] += dp[0];
            nxtdp[1] += dp[1];
            nxtdp[2] += dp[2];
        } else if (p == 50) {
            nxtdp[1] += dp[0] + dp[1] + dp[2];
        } else {
            nxtdp[0] += dp[2];
            nxtdp[1] += dp[1];
            nxtdp[2] += dp[0];
        }
        dp = nxtdp;
    }
    cout << dp[2].val() << '\n';
}
0