結果

問題 No.1151 チャレンジゲーム
ユーザー tokusakuraitokusakurai
提出日時 2020-08-07 22:56:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,336 bytes
コンパイル時間 2,471 ms
コンパイル使用メモリ 204,556 KB
実行使用メモリ 10,252 KB
最終ジャッジ日時 2023-10-25 03:56:17
合計ジャッジ時間 28,329 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 3 ms
4,352 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 3 ms
4,352 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 412 ms
7,032 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 688 ms
10,252 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 254 ms
10,252 KB
testcase_49 AC 796 ms
10,252 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:36:9: warning: '*sum[<unknown>]' may be used uninitialized [-Wmaybe-uninitialized]
   36 |     int all = sum[(1<<N)-1];
      |         ^~~
main.cpp:67:41: warning: '*res[0]' may be used uninitialized [-Wmaybe-uninitialized]
   67 |             dp[i][j][0] = memo1[a][res[a]], dp[i][j][1] = memo2[a][res[a]];
      |                                    ~~~~~^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    int sum[1<<N];
    rep(i, 1<<N){
        sum[i] = 0;
        rep(j, N) if(i&(1<<j)) sum[i] += A[j];
    }
    int all = sum[(1<<N)-1];
    ld dp[1<<N][201][2];
    rep(i, 1<<N) rep(j, 201) rep(k, 2) dp[i][j][k] = 0.0;
    rep(j, 201){
        if(j*2 > all) rep(k, 2) dp[0][j][k] = 1.0;
    }
    rep(i, 1<<N){
        if(i == 0) continue;
        rep(j, 201){
            ld memo1[N][N], memo2[N][N];
            fill(memo1[0], memo1[N], -1.0), fill(memo2[0], memo2[N], -1.0);
            rep(k, N) rep(l, N){
                if(!(i&(1<<k)) || !(i&(1<<l))) continue;
                if(j+A[k] > 200) continue;
                ld s = ld(1)/ld(A[k]), t = ld(1)/ld(A[l]);
                ld p = dp[i^(1<<k)][j+A[k]][1], q = dp[i^(1<<l)][j][0];
                ld x = (s*p+(1-s)*t*q)/(s+t-s*t);
                ld y = t*q+(1-t)*x;
                memo1[k][l] = x, memo2[k][l] = y;
            }
            int res[N];
            rep(k, N){
                res[k] = -1;
                rep(l, N){
                    if(memo1[k][l] < -EPS) continue;
                    if(res[k] == -1) res[k] = l;
                    if(memo1[k][l] < memo1[k][res[k]]) res[k] = l;
                }
            }
            int a = 0;
            rep(k, N) if(memo1[k][res[k]] > memo1[a][res[a]]) a = k;
            dp[i][j][0] = memo1[a][res[a]], dp[i][j][1] = memo2[a][res[a]];
        }
    }
    cout << sp(10) << dp[(1<<N)-1][0][0] << endl;
}
0