結果

問題 No.398 ハーフパイプ(2)
ユーザー mamekinmamekin
提出日時 2016-10-07 15:50:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,821 bytes
コンパイル時間 1,017 ms
コンパイル使用メモリ 107,932 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2023-09-09 23:08:03
合計ジャッジ時間 2,083 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,228 KB
testcase_01 AC 13 ms
7,296 KB
testcase_02 AC 13 ms
7,264 KB
testcase_03 AC 12 ms
7,048 KB
testcase_04 AC 13 ms
7,140 KB
testcase_05 AC 13 ms
7,208 KB
testcase_06 AC 13 ms
7,280 KB
testcase_07 AC 13 ms
7,192 KB
testcase_08 AC 13 ms
7,136 KB
testcase_09 AC 12 ms
7,240 KB
testcase_10 AC 13 ms
7,264 KB
testcase_11 AC 12 ms
7,184 KB
testcase_12 AC 12 ms
7,176 KB
testcase_13 AC 13 ms
7,168 KB
testcase_14 AC 13 ms
7,140 KB
testcase_15 AC 13 ms
7,260 KB
testcase_16 AC 13 ms
7,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    const int n = 6;
    const int maxScore = (n - 2) * 100;

    vector<vector<vector<long long> > > dp(n, vector<vector<long long> >(101, vector<long long>(maxScore + 1, 0)));
    dp[0][0][0] = 1;
    for(int i=1; i<=n; ++i)
        dp[0][0][0] *= i;

    for(int i=0; i<n; ++i){
        vector<vector<vector<long long> > > nextDp(n, vector<vector<long long> >(101, vector<long long>(maxScore + 1, 0)));
        for(int a=0; a<n; ++a){
            for(int b=0; b<=100; ++b){
                for(int c=0; c<=maxScore; ++c){
                    if(dp[a][b][c] == 0)
                        continue;

                    for(int b2=b; b2<=100; ++b2){
                        int c2 = c;
                        if(0 < i && i < n - 1)
                            c2 += b2;

                        if(i > 0 && b == b2)
                            nextDp[a+1][b2][c2] += dp[a][b][c] / (a + 2);
                        else
                            nextDp[0][b2][c2] += dp[a][b][c];
                    }
                }
            }
        }
        dp.swap(nextDp);
    }

    int x1, x2;
    char c;
    cin >> x1 >> c >> x2;
    int sum = (x1 * 100 + x2) * (n - 2) / 100;

    long long ans = 0;
    for(int a=0; a<n; ++a){
        for(int b=0; b<=100; ++b){
            ans += dp[a][b][sum];
        }
    }
    cout << ans << endl;

    return 0;
}
0