結果

問題 No.108 トリプルカードコンプ
ユーザー nvt4snvt4s
提出日時 2019-05-26 19:39:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 1,400 bytes
コンパイル時間 1,644 ms
コンパイル使用メモリ 170,264 KB
実行使用メモリ 14,204 KB
最終ジャッジ日時 2023-10-17 18:02:43
合計ジャッジ時間 2,808 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
14,176 KB
testcase_01 AC 6 ms
14,176 KB
testcase_02 AC 6 ms
14,176 KB
testcase_03 AC 6 ms
14,176 KB
testcase_04 AC 6 ms
14,176 KB
testcase_05 AC 6 ms
14,176 KB
testcase_06 AC 6 ms
14,176 KB
testcase_07 AC 10 ms
14,204 KB
testcase_08 AC 6 ms
14,192 KB
testcase_09 AC 6 ms
14,184 KB
testcase_10 AC 6 ms
14,176 KB
testcase_11 AC 6 ms
14,176 KB
testcase_12 AC 6 ms
14,176 KB
testcase_13 AC 6 ms
14,184 KB
testcase_14 AC 6 ms
14,180 KB
testcase_15 AC 5 ms
14,176 KB
testcase_16 AC 6 ms
14,180 KB
testcase_17 AC 6 ms
14,176 KB
testcase_18 AC 9 ms
14,196 KB
testcase_19 AC 7 ms
14,192 KB
testcase_20 AC 6 ms
14,184 KB
testcase_21 AC 8 ms
14,192 KB
testcase_22 AC 6 ms
14,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int N;
double memo[110][110][110];
int X, Y, Z;


double dfs(int x, int y, int z){
    if(memo[x][y][z] != -1) return memo[x][y][z];
    memo[x][y][z] = 0;
    double exp_num = 1.0 * N / (N - z);//自己ループする回数
    if(x != N) memo[x][y][z] += (dfs(x+1, y, z) + exp_num) * (N - x) / (N - z);//0枚
    if(y != x) memo[x][y][z] += (dfs(x, y+1, z) + exp_num) * (x - y) / (N - z);//1枚
    if(z != y) memo[x][y][z] += (dfs(x, y, z+1) + exp_num) * (y - z) / (N - z);//2枚
    return memo[x][y][z];
}

int main(void){
    cin >> N;
    for(int i = 0; i < N; i++){
        int A; cin >> A;
        if(A >= 1) X++;
        if(A >= 2) Y++;
        if(A >= 3) Z++;
    }
    //X 1枚以上持っている枚数
    //Y 2枚以上持っている枚数
    //Z 3枚以上持っている枚数
    for(int i = 0; i < 110; i++){
        for(int j = 0; j < 110; j++){
            for(int k = 0; k < 110; k++){
                memo[i][j][k] = -1;
            }
        }
    }
    cout << fixed << setprecision(10) << dfs(X, Y, Z) << endl;
}
0