結果

問題 No.398 ハーフパイプ(2)
ユーザー purple_jwlpurple_jwl
提出日時 2016-07-16 14:08:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,550 bytes
コンパイル時間 1,164 ms
コンパイル使用メモリ 148,420 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 22:08:04
合計ジャッジ時間 2,232 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 29;

int nCr[10][10];

ll calc(vector<int> score) {
    if (score.front() < 0 || 100 < score.back()) return 0;

    int n = sz(score);
    int r = 1;
    int res = 1;

    int len = sz(score);
    score.eb(-1);

    rep (i, len) {
        if (score[i] == score[i + 1]) r++;
        else {
            res *= nCr[n][r];
            n -= r;
            r = 1;
        }
    }

    return res;
}

int main() {
    nCr[0][0] = 1;
    rep (i, 10) rep(j, 10) {
        if (i) nCr[i][j] += nCr[i - 1][j];
        if (i && j) nCr[i][j] += nCr[i - 1][j - 1];
    }

    double x;
    cin >> x;

    ll ans = 0;
    REP (i, 0, 101) REP (j, i, 101) REP (k, j, 101) {
        int l = (int)(x * 4) - i - j - k;
        if (k > l) continue;
        ans += calc(vector<int>{i - 1, i, j, k, l, l + 1}) * i * (100 - l);
        ans += calc(vector<int>{i - 1, i, j, k, l, l    }) * i;
        ans += calc(vector<int>{i    , i, j, k, l, l + 1})     * (100 - l);
        ans += calc(vector<int>{i    , i, j, k, l, l});
    }

    cout << ans << endl;
}
0