結果

問題 No.567 コンプリート
ユーザー snrnsidysnrnsidy
提出日時 2021-11-21 00:23:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 836 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 4,276 ms
コンパイル使用メモリ 199,812 KB
実行使用メモリ 503,552 KB
最終ジャッジ日時 2023-09-03 12:36:20
合計ジャッジ時間 3,603 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 836 ms
503,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
 
using namespace std;

double dp[1000001][1<<6];
vector <int> p[1<<6];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    for(int i=0;i<(1<<6);i++)
    {
        int bcnt = 0;
        for(int j=0;j<6;j++)
        {
            if((i&(1<<j)))
            {
                bcnt++;
            }
            else
            {
                p[i].push_back(j);
            }
        }
    }
    dp[0][0] = 1;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<(1<<6);j++)
        {
            if(dp[i][j]<=0) continue;
            int cnt = p[j].size();
            dp[i+1][j] += ((dp[i][j]*cnt/6));
            for(auto k : p[j])
            {
                int bitmask = (j | (1<<k));
                dp[i+1][bitmask] += (dp[i][j]/6);
            }
        }
    }

    cout << fixed;
    cout.precision(16);

    cout << dp[n][63] << '\n';

    return 0;
}
0