結果

問題 No.398 ハーフパイプ(2)
ユーザー parukiparuki
提出日時 2016-07-16 00:02:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,811 bytes
コンパイル時間 1,839 ms
コンパイル使用メモリ 173,812 KB
実行使用メモリ 5,940 KB
最終ジャッジ日時 2023-09-09 22:04:16
合計ジャッジ時間 2,902 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,796 KB
testcase_01 AC 23 ms
5,600 KB
testcase_02 AC 20 ms
5,720 KB
testcase_03 AC 20 ms
5,788 KB
testcase_04 AC 21 ms
5,676 KB
testcase_05 AC 23 ms
5,668 KB
testcase_06 AC 10 ms
5,592 KB
testcase_07 AC 16 ms
5,788 KB
testcase_08 AC 24 ms
5,592 KB
testcase_09 AC 22 ms
5,940 KB
testcase_10 AC 23 ms
5,592 KB
testcase_11 AC 24 ms
5,668 KB
testcase_12 AC 22 ms
5,940 KB
testcase_13 AC 22 ms
5,680 KB
testcase_14 AC 23 ms
5,604 KB
testcase_15 AC 24 ms
5,656 KB
testcase_16 AC 23 ms
5,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

vector<vi> PT6 = {{1,1,1,1,1,1},{2,1,1,1,1},{2,2,1,1},{2,2,2},{3,1,1,1},{3,2,1},{3,3},{4,1,1},{4,2},{5,1},{6}};

ll dp[7][401][101];

int main(){
    int x, y;
    scanf("%d.%d", &x, &y);
    int sum = (x * 100 + y) * 4 / 100;

    ll ans = 0;
    
    each(pt6, PT6){
        if(pt6[0] == 6){
            if(sum % 4 == 0 && 0 <= sum / 4 && sum / 4 <= 100){
                ++ans;
            }
            continue;
        }
        sort(all(pt6));
        ll P = 1;
        for(int i = 1; i <= 6; ++i)P *= i;
        each(p, pt6)for(int i = 1; i <= p; ++i)P /= i;
        do{
            int n = sz(pt6);
            MEM(dp, 0);
            rep(i, 101){
                int cnt = pt6[0];
                int s = i*(cnt - 1);
                dp[1][s][i] = 1;
            }
            FOR(i, 1, sz(pt6)){
                int cnt = pt6[i];
                rep(s, sum+1)rep(pre, 101)if(dp[i][s][pre]){

                    FOR(nex, pre + 1, 101){
                        int ns = s + cnt*nex;
                        if(i == sz(pt6) - 1)ns -= nex;
                        dp[i + 1][ns][nex] += dp[i][s][pre];
                    }
                }
            }
            
            rep(i,101)ans += P * dp[n][sum][i];
        } while(next_permutation(all(pt6)));
    }
    cout << ans << endl;
}
0