結果

問題 No.108 トリプルカードコンプ
ユーザー recososorecososo
提出日時 2021-05-20 00:17:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,281 bytes
コンパイル時間 2,249 ms
コンパイル使用メモリ 207,436 KB
実行使用メモリ 91,036 KB
最終ジャッジ日時 2024-04-18 13:57:01
合計ジャッジ時間 8,865 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e6+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
map<vector<int>,double> mp;
double f(vector<int> a){
    if(mp.count(a)) return mp[a];
    bool fin=true;
    double n=a.size();
    REP(i,a.size()) if(a[i]!=3) fin=false;
    if(fin) return mp[a]=0;
    double res=0;
    double cnt=0;
    REP(i,n){
        if(a[i]==3) cnt++;
        else{
            a[i]++;
            res+=(f(a)+1)/n;
            a[i]--;
        }
    }
    return mp[a]=res*n/(n-cnt)+cnt/(n-cnt);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
        chmin(a[i],3);
    }
    cout << fixed << setprecision(10) << f(a) << endl;
}
0